2d Array mit fixer variable füllen

  • Hi Autoit-Fans,

    ich stehe mal wieder vor einem Problem:

    Mittels unten stehender Funktion möchte ich gern aus dem ActiveDirectory Werte auslesen sofern vorhanden.

    Leider bricht die Funktion ab, sofern das Array keinen Wert enthält.

    Gibt es eine Möglichkeit in der zweiten Dimension den Wert des Arrays, sofern nicht vorhanden zu füllen?

    Habe es versucht über if $aProperties[1][1] > "1" then zu lösen - aber AutoIt meckert bereits "Array variable has incorrect number of subscripts or subscript dimension range exceeded."

    Es wird also vorkommen, dass es Nutzer gibt, die Einträge bei "msRADIUSFramdedIPAdress" haben und bei manchen nicht.

    Ich möchte einfach alle Nutzer in einer *.txt-Datei nacheinander abfragen und dann in einem Export ausgeben ob sie einen Eintrag haben oder nicht.

    Hoffe auf eure Unterstützung. :thumbup:

  • "Array variable has incorrect number of subscripts or subscript dimension range exceeded."

    _AD_GetObjectProperties gibt dir bestimmt ein eindimensionales Array zurück, deshalb kannst du auch nicht auf die 2. Dimension zugreifen.

    Du kannst mit UBound prüfen wie groß eine bestimmte Dimension ist, und ob sie überhaupt existiert.

  • Die Funktion _AD_GetObjectProperties sieht wie folgt aus:

    _AD_GetObjectProperties

    _AD_GetObjectProperties($vObject = @UserName, $sProperties = "", $bSort = True)
    Description: Returns a two-dimensional array of all or selected properties and their values of an object in readable form.

    Return Value:

    Success - Returns a one based two-dimensional array with all properties and their values of an object in readable form

    Failure - "" or property name, sets @error to:

    1 - $vObject could not be found

    2 - No values for the specified property. The name of the property in error is returned as the function result

    3 - Error retrieving $vObject. @Extended is set to the error returned by LDAP

    Parameters:

    $vObject - Optional: SamAccountName, FQDN or ADSPath of the object to retrieve properties from (e.g. computer, user, group ...) (default = @Username)

    Can be of type object as well. Useful to get properties for a schema or configuration object (see _AD_ListRootDSEAttributes)

    $sProperties - Optional: Comma separated list of properties to return (default = "" = return all properties)

    $bSort - Optional: True specifies that the array will be sorted on property name (default = True)

    Remarks: Dates are returned in format: YYYY/MM/DD HH:MM:SS local time of the calling user (AD stores all dates in UTC - Universal Time Coordinated)

    Exception: AD internal dates like "whenCreated", "whenChanged" and "dSCorePropagationData". They are returned as UTC

    NT Security Descriptors are returned as: Control:nn, Group:Domain\Group, Owner:Domain\Group, Revision:nn

    No error is returned if there are properties in $sProperties that are not available for the selected object ;+

    Properties are returned in alphabetical order. If $sProperties is set to "samaccountname,displayname" the returned array will contain

    displayname as the first and samaccountname as the second row.

    Author: Sundance

    Modified: water

  • Aber der Hinweis mit dem Ubound war perfekt!!!

    Habe nun alles was ich brauche ;)

    Vielen Dank.

    Hier der neue Code:

  • Lashandan 9. Januar 2019 um 11:28

    Hat das Label von [ offen ] auf [ gelöst ] geändert.