Jump to content

AD: Nested Group Membership: Get the "chain"


Recommended Posts

Hello,

 

<edit>

In this posting below you will find a script to get an Active Directory User's Group Memberships including nested Group Memberships:

 

</edit>

quite a while ago I started this thread: https://www.autoitscript.com/forum/topic/193984-ad-member-of-group-in-group/

 

#include <AD.au3>

_AD_Open()
$user=_AD_SamAccountNameToFQDN("ASP")
$group=_AD_SamAccountNameToFQDN("daten-Bestellung-QS_lesen")
$result=_AD_IsMemberOf($group,$user,false,True) ; $Group is the 1st, $User the 2nd param
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $result = ' & $result & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

_AD_Close()

this works fine, thanks for the help in the other thread.

Howto to get the "chain" of groups for nested group memberships?

In AD.AU3 I found the function _AD_RecursiveGetMemberOf(), which might be an approach, (get all the group content then sort out what's needed), just wondering if there is another function that I've overlooked, that directly would give me the "nested membership chain" *ONLY*?

 

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to post
Share on other sites

Hello,

This is now working quite fine for me. Maybe someone else can make use of this script, at least as a "starter" ...

 

It's giving an output like this one

 

Dieses Script: \\file03\file03-data01\DATEN\EDV\Anleitungen Hilfe Doku\microsoft\AD\Auswertung-Rechte-Zustand\Get-UserInGroupsWithNestedGroups.exe
Ausgeführt von AD\Rudi auf PC-Rudi
Diese  Ergebnis-Datei: C:\Users\admin\AppData\Local\Temp\Gruppenauswertung-Fuer-TestUserNestedGroups_2019-01-24_17h-16m-10_Result.txt
Ausgewerteter AD User: TestUserNestedGroups
----------------------------------------------------------------------------
............................................ 

Gruppe: TestNestedGroup-A
    Direkt
............................................ 

Gruppe: TestNestedGroup-B
    Direkt
............................................ 

Gruppe: TestNestedGroup-Sub1
        Nested: TestNestedGroup-A MemberOf TestNestedGroup-Sub1
............................................ 

Gruppe: TestNestedGroup-Sub2
        Nested: TestNestedGroup-A MemberOf TestNestedGroup-Sub2
............................................ 

Gruppe: TestNestedGroup-Sub2-1
    Direkt
        Nested: TestNestedGroup-B MemberOf TestNestedGroup-Sub2-1
        Nested: TestNestedGroup-A MemberOf TestNestedGroup-Sub2 MemberOf TestNestedGroup-Sub2-1
----------------------------------- EOF --------------------------------------------

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Description=Für einen einzelnen AD User Gruppenmitgliedschaften mit Verschachtelungen darstellen
#AutoIt3Wrapper_Res_Fileversion=1.0.0.4
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
#AutoIt3Wrapper_Res_LegalCopyright=(c) 2019 by Rudolf Thilo, IT-Beratung Rudolf Thilo
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Res_Language=1031
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <AD.au3>
#include <File.au3>
#include <Debug.au3>


$SAM = InputBox("Get Group Memberships including nested ones","Enter user's SAMACCOUNTNAME","SomeUsersSAMaccountName")
_AD_Open()
$user = _AD_SamAccountNameToFQDN($SAM)
; $result=_AD_IsMemberOf($user,$group,false,True)
$aMemberOf = _AD_RecursiveGetMemberOf($user, 100, True, False)

_ArraySort($aMemberOf, 0, 1)

Dim $aResult[1][2] = [[0]]


; _DebugArrayDisplay($aMemberOf)

$MemberOf = " MemberOf "

For $a = 1 To $aMemberOf[0]
    $NextGroup = $aMemberOf[$a]
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $NextGroup = ' & $NextGroup & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    $aNested = StringSplit($NextGroup, "|")
    If IsArray($aNested) Then
        Switch $aNested[0]
            Case 1 ; nicht verschachtelt
                $iFound = _ArraySearch($aResult, $aNested[1], 1, 0, 0, 0, 1, 0) ; Start, Stop (alles), caseinsensitive, tolerant match, vorwärts, Spalte 0
                If @error Then
                    _ArrayAdd($aResult, $NextGroup & "|Direkt")
                    ; _DebugArrayDisplay($aResult, "ResultArray ergänzt")
                Else
                    ; _DebugArrayDisplay($aResult, "Gefunden an Pos. " & $iFound & " --> " & $aNested[1])
                EndIf
            Case Else ; verschachtelt
                ConsoleWrite("--> Verschachtelt: " & $NextGroup & @CRLF)
                ; _DebugArrayDisplay($aNested,$a & " - Verschachtelt: " & $NextGroup)
                $foo = "Nested: "
                For $x = $aNested[0] To 1 Step -1
                    $foo &= $aNested[$x] & $MemberOf
                Next
                If StringRight($foo, StringLen($MemberOf)) = $MemberOf Then $foo = StringTrimRight($foo, StringLen($MemberOf))
                ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $foo = ' & $foo & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
                $iFound = _ArraySearch($aResult, $aNested[1], 1, 0, 0, 0, 1, 0) ; Start, Stop (alles), caseinsensitive, tolerant match, vorwärts, Spalte 0
                $err=@error
                If $err Then ; noch nicht im Array eingetragen
                _ArrayAdd($aResult, $aNested[1] & "|" & $foo)
                ; _DebugArrayDisplay($aResult,$aNested[1] & " eingetragen")
                Else
                $aResult[$iFound][1] &= "*" & $foo
                ;_DebugArrayDisplay($aResult,$aNested[1] & " an Pos. " & $iFound & " ergänzt")
                EndIf
        EndSwitch
    Else
        MsgBox(48, "Fehler", "Konnte Gruppenstring nicht zerlegen" & @CRLF & $NextGroup)
    EndIf
Next


_ArraySort($aResult,0,1)
$aResult[0][0]=UBound($aResult)-1
; _DebugArrayDisplay($aResult,"Ergebnis der Auswertung")




$ResultFile=@TempDir & "\Gruppenauswertung-Fuer-" & $SAM & "_" & @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & "h-" & @MIN & "m-" & @SEC & "_Result.txt"
$hResFile=FileOpen($ResultFile,8+2)

FileWriteLine($hResFile,"Dieses Script: " & @ScriptFullPath)
FileWriteLine($hResFile,"Ausgeführt von " & @LogonDomain & "\" & @UserName & " auf " & @ComputerName)
FileWriteLine($hResFile,"Diese  Ergebnis-Datei: " & $ResultFile)
FileWriteLine($hResFile,"Ausgewerteter AD User: " & $SAM)
FileWriteLine($hResFile,"----------------------------------------------------------------------------")
for $R = 1 to $aResult[0][0]
    FileWriteLine($hResFile,"............................................ ")
    FileWriteLine($hResFile,"")
    FileWriteLine($hResFile,"Gruppe: " & $aResult[$R][0])
    $Quellen=$aResult[$R][1]
    $aQuellen=StringSplit($Quellen,"*")
    if IsArray ($aQuellen) Then
        for $Q = 1 to $aQuellen[0]
            FileWriteLine($hResFile,@TAB & StringReplace($aQuellen[$Q],"Nested: ", @TAB & "Nested: "))
        Next
        Else
        FileWriteLine($hResFile,"Zerlegen des Array Elements mit den Gruppen-Infos gescheitert!")
        FileWriteLine($hResFile,@TAB & $aResult[$r][1])
        FileWriteLine($hResFile,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
        EndIf
Next
FileWriteLine($hResFile,"----------------------------------- EOF --------------------------------------------")
FileClose($hResFile)
ShellExecute($ResultFile)






#cs
_DebugArrayDisplay($aNested, "Verschachtelt: " & $NextGroup)
For $x = $aNested[0] To 1 Step -1
    $iFound = _ArraySearch($aResult, $aNested[$x], 1, 0, 0, 0, 1, 0) ; Start, Stop (alles), caseinsensitive, tolerant match, vorwärts, Spalte 0
    $err = @error
    ConsoleWrite($aNested[$x] & " an Pos. " & $x & " schon da!" & @CRLF)
    If $err Then ; noch nicht im Array eingetragen.
        ConsoleWrite("Nix da,  $x = " & $x & ", $aNested[" & $x & "] = " & $aNested[$x] & @CRLF)
        $foo = "Nested: "
        For $Rest = $x To 1 Step -1
            $foo &= $aNested[$Rest] & $MemberOf
        Next
        If StringRight($foo, StringLen($MemberOf)) = $MemberOf Then $foo = StringTrimRight($foo, StringLen($MemberOf))
        _DebugArrayDisplay($aResult, "Nix da: " & $x & "=" & $aNested[$x] & " - " & $NextGroup)
    Else ; schon im Result Array enthalten
        $foo = "Nested: "
        For $Rest = $x To 1 Step -1
            $foo &= $aNested[$Rest] & $MemberOf
        Next
        If StringRight($foo, StringLen($MemberOf)) = $MemberOf Then $foo = StringTrimRight($foo, StringLen($MemberOf))
        $aResult[$iFound][1] &= "*" & $foo
        _DebugArrayDisplay($aResult, "*Dabei* Index = " & $iFound & " - " & $x & "=" & $aNested[$x] & " - " & $NextGroup)
    EndIf
Next
#ce




Exit




$GroupDir = "h:\daten\edv\Anleitungen Hilfe Doku\microsoft\ad\Gruppen"


$aGroupFiles = _FileListToArray($GroupDir, "Daten-*-group.txt", 1, 0)

_DebugArrayDisplay($aGroupFiles)

For $i = 1 To $aGroupFiles[0]
    $GroupFile = $aGroupFiles[$i]
    $GroupName = StringReplace($GroupFile, "-group.txt", "")
    $GroupFileFPFN = $GroupDir & "\" & $GroupFile
    If FileExists($GroupFileFPFN) Then
        $aContent = FileReadToArray($GroupFileFPFN)
        If Not IsArray($aContent) Then
            ConsoleWrite("Fehler beim einlesen der vorhandenen Datei!" & @CRLF)
            ConsoleWrite($GroupFileFPFN & @CRLF)
            ConsoleWrite(" # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #" & @CRLF)
            ContinueLoop
        EndIf
        $Member = ""
        #Region Prüfen, ob direkt Mitglied in der Gruppe, Auslesen aus dem AD (tatsächlich wirksamer Zustand unabhängig vom Eintrag in der Datei
        $group = _AD_SamAccountNameToFQDN($GroupName)
        $Direkt = _AD_IsMemberOf($group, $user, False, False)
        $Verschachtelt = _AD_IsMemberOf($group, $user, False, True)
        If $Direkt Then
            $Member &= "Gruppenmitglied (direkt): " & $group & @CRLF
        ElseIf $Verschachtelt Then
            $Member &= "Gruppenmitglied (verschachtelt): " & $group & @CRLF
        EndIf
        #EndRegion Prüfen, ob direkt Mitglied in der Gruppe, Auslesen aus dem AD (tatsächlich wirksamer Zustand unabhängig vom Eintrag in der Datei

        #Region Prüfen, ob direkt oder indirekt in den Eintragungen in dieser Gruppendatei "dabei"
        For $L = 0 To UBound($aContent) - 1
            $Zeile = $aContent[$L]
            $Zeile = StringStripWS($Zeile, 8)
            $Zeile = StringLeft($Zeile, StringInStr($Zeile, ";") - 1)
            If $Zeile = $user Then
                $Member &= "Direkt eingetragen"
            Else
                $group = _AD_SamAccountNameToFQDN($Zeile)
                $Direkt = _AD_IsMemberOf($group, $user, False, False)
                $Verschachtelt = _AD_IsMemberOf($group, $user, False, True)
                If $Direkt Then
                    $Member &= "Eingetragen in Datei: Gruppenmitglied (direkt): " & $group & @CRLF
                ElseIf $Verschachtelt Then
                    $Member &= "Eingetragen in Datei: Gruppenmitglied (verschachtelt): " & $group & @CRLF
                EndIf

            EndIf
        Next
        If $Member Then
            ConsoleWrite("------ " & $GroupName & " ----------" & @CRLF)
            ConsoleWrite($Member & @CRLF)
            ConsoleWrite("" & @CRLF)
        EndIf
    Else
        ConsoleWrite("Datei fehlt: " & $GroupFileFPFN & @CRLF)
    EndIf
Next

_AD_Close()

 

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By kovlad
      My solution is to write nested arrays without copying.
      The problem was described hier.
       
      Function:
      #include <Array.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ArrayNestedSet ; Description ...: Assigns a value to an element of a nested 1D array. ; Syntax ........: _ArrayNestedSet(ByRef $aArray, $vIndex, $vValue) ; Parameters ....: $aArray - an array of arrays. ; $vIndex - an index or 1d-array of indexes; ; a size if $vValue not defined (zero to delete). ; $vValue - a value (create, resize or delete if not defined). ; ; Return values .: on success - 1 ; @extended - nesting level of operation ; on failure - 0 ; @extended - nesting level of error ; @error = 1 - invalid array ; @error = 2 - invalid index ; Author ........: ; Modified ......: kovlad ; Remarks .......: ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/topic/185638-assign-a-value-to-an-array-in-array-element/ ; https://www.autoitscript.com/trac/autoit/ticket/3515?replyto=description ; Example .......: Yes ; =============================================================================================================================== Func _ArrayNestedSet(ByRef $aArray, $vIndex, $vValue = Default) Local $extended = @extended + 1 If IsArray($vIndex) Then If UBound($vIndex, 0) <> 1 Then _ Return SetError(2, $extended) If UBound($vIndex) > 1 Then If UBound($aArray, 0) <> 1 Then _ Return SetError(1, $extended) ; keep index for this array Local $i = $vIndex[0] If $i < 0 Or UBound($aArray) <= $i Then _ Return SetError(2, $extended) ; delete index of this array _ArrayDelete($vIndex, 0) ; recursive function call Local $return = _ArrayNestedSet($aArray[$i], $vIndex, $vValue) If @error Then Return SetError(@error, @extended + 1, 0) Else Return SetExtended(@extended + 1, 1) EndIf Else $vIndex = $vIndex[0] EndIf EndIf If $vValue = Default Then If $vIndex < 0 Then _ Return SetError(2, $extended) If $vIndex = 0 Then ; delete array and free memory $aArray = 0 Return SetExtended($extended, 1) EndIf If UBound($aArray, 0) = 1 Then ; resize array keeping data ReDim $aArray[$vIndex] Return SetExtended($extended, 1) Else ; create new nested array Local $aTmp[$vIndex] $aArray = $aTmp Return SetExtended($extended, 1) EndIf Else If UBound($aArray) <= $vIndex Then _ Return SetError(2, $extended + 1) ; set value of array entry $aArray[$vIndex] = $vValue Return SetExtended($extended, 1) EndIf EndFunc  
      Examples:
      ; write value to 1st nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : write value to 1st nested array" & @CRLF) Local $aTmp1[4] = [1,2,3,4] _ArrayDisplay($aTmp1, "$aTmp1") Local $aArray[2] = [$aTmp1] ConsoleWrite( _ "_ArrayNestedSet($aArray[0], 3, 14) = " & _ArrayNestedSet($aArray[0], 3, 14) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay($aArray[0], "$aArray[0]") ; resize 1st nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : resize 1st nested array" & @CRLF) ConsoleWrite( _ "_ArrayNestedSet($aArray[0], 8) = " & _ArrayNestedSet($aArray[0], 8) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay($aArray[0], "$aArray[0]") ; write array to 1st nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : write array to 1st nested array" & @CRLF) Local $aTmp11[4] = [11,12,13,14] _ArrayDisplay($aTmp11, "$aTmp11") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], 2, $aTmp11) = " & _ArrayNestedSet($aArray[0], 2, $aTmp11) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay(($aArray[0])[2], "($aArray[0])[2]") ; write value to 2nd nested array using index array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : write value to 2nd nested array using index array" & @CRLF) Local $aIndex1[2] = [2,3] _ArrayDisplay($aIndex1, "$aIndex1") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex1, 140) = " & _ArrayNestedSet($aArray[0], $aIndex1, 140) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay(($aArray[0])[2], "($aArray[0])[2]") ; resize 2nd nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : resize 2nd nested array" & @CRLF) Local $aIndex1[2] = [2,8] _ArrayDisplay($aIndex1, "$aIndex1") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex1) = " & _ArrayNestedSet($aArray[0], $aIndex1) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay(($aArray[0])[2], "($aArray[0])[2]") ; create new 3rd nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : create new 3rd nested array" & @CRLF) Local $aIndex2[3] = [2,7,6] _ArrayDisplay($aIndex2, "$aIndex2") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex2) = " & _ArrayNestedSet($aArray[0], $aIndex2) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay((($aArray[0])[2])[7], ")($aArray[0])[2])[7]") ; delete 3rd nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : delete 3rd nested array" & @CRLF) Local $aIndex3[3] = [2,7,0] _ArrayDisplay($aIndex3, "$aIndex2") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex3) = " & _ArrayNestedSet($aArray[0], $aIndex3) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF) ConsoleWrite("IsArray((($aArray[0])[2])[7]) = " & IsArray((($aArray[0])[2])[7]) & @CRLF & @CRLF) ; write 0 in 1st nested array to delete the 2nd nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : write 0 in 1st nested array to delete the 2nd nested array" & @CRLF) Local $aIndex4[1] = [2] _ArrayDisplay($aIndex4, "$aIndex4") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex4, 0) = " & _ArrayNestedSet($aArray[0], $aIndex4, 0) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF) ConsoleWrite("IsArray(($aArray[0])[2]) = " & IsArray(($aArray[0])[2]) & @CRLF & @CRLF) ; delete 1st nested array (same as '$aArray[0] = 0') ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : delete 1st nested array (same as '$aArray[0] = 0')" & @CRLF) Local $aIndex5[1] = [0] _ArrayDisplay($aIndex5, "$aIndex5") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex5) = " & _ArrayNestedSet($aArray[0], $aIndex5) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF) ConsoleWrite("IsArray($aArray[0]) = " & IsArray($aArray[0]) & @CRLF & @CRLF)  
    • By LxP
      I'm trying to pass a nested array to a function, such that the function alters the inner array.
      I was surprised to find that this minimal reproducible example, despite its use of ByRef, seems to pass a copy of the inner array to the function:
      #include <Array.au3> ; a boring old array Local $aInnerArray[5] = [1, 2, 3, 4, 5] ; a one-element array containing a reference to the other array Local $aOuterArray[1] = [$aInnerArray] ; intention: take a nested array and alter its inner array ; reality: the inner array seems to be getting copied Func ChangeIt(ByRef $aOuter) Local $aInner = $aOuter[0] $aInner[2] = 0 EndFunc ; Expected: [1, 2, 3, 4, 5] ; Actual: [1, 2, 3, 4, 5] ✔ _ArrayDisplay($aInnerArray, 'Before') ; $aOuterArray passed by-ref, should receive reference to $aInnerArray ; Therefore should change $aInnerArray to [1, 2, 0, 4, 5] ChangeIt($aOuterArray) ; Expected: [1, 2, 0, 4, 5] ; Actual: [1, 2, 3, 4, 5] ✘ _ArrayDisplay($aInnerArray, 'After') I suspect that either:
      the copy is taking place in the first line of the function (I couldn't find a way to access the inner array without first assigning it to a variable though); or ByRef doesn't propagate into inner levels of the data structure being passed, which seems less likely to me. Could someone please point me in the right direction to get this working as intended?
      Update: the answer
      ; WRONG: ; a one-element array containing a reference to the other array Local $aOuterArray[1] = [$aInnerArray] The assumption I made about this code is wrong—it actually copies $aInnerArray into $aOuterArray, so there are now two unrelated $aInnerArray instances.  It is not possible to store arrays in other arrays by reference.
      If it is necessary to refer to a mutable array in multiple places, consider holding it in a global variable.  Where a collection of mutable arrays needs to be accessed in multiple places (as in my case), consider storing them in a global array and referring to each sub-array by index (also known as the Registry pattern).
    • By tweakster2010
      Hello All,
      It has been a long time since I posted, role changes etc involving work and I finally am back to modifying a program I write in AutoIt that has AD integration. I am at a point where we are modifying our structure where I am validating users access via what Distribution List they belong to in our AD OU's. What I have run into is the OU is a sub OU of a sub OU now. Meaning: CN=team, OU=DL, OU=Groups, DC=business.com(working), is now CN=Team, OU=SubDL, OU=DL, OU=Groups, DC=business.com (Not working).  Just curious if the AD functionality should be able to read it or maybe I am missing something?
       
      ElseIf _AD_IsMemberOf("CN=Team,OU=Distribution Lists,OU=Groups,DC=business,DC=com", $sFQDN_User) Then #works for primary Distro ElseIf _AD_IsMemberOf("CN=Team,OU=SubDL,OU=Distribution Lists,OU=Groups,DC=business,DC=com", $sFQDN_User) Then #fails for subOU of DL How I am accessing AD to get the information:
      _AD_Open() Global $aUser = _AD_GetObjectsInOU("", "(&(objectCategory=person)(objectClass=user)(samaccountname=" & @UserName & "))", 2, "ADsPath,Displayname,distinguishedName") Global $sDisplayName0 = $aUser[1][1] ; Displayname ;MsgBox(0,"", $sDisplayName0) If StringLeft($sDisplayName0, 2) = "9-" Then $Displaynamestring = StringTrimLeft($sDisplayName0, 2) $Displaynamestring1 = StringTrimRight($Displaynamestring, 6) The error code generated is a 1 with a 0 extended. I assume it is because it cannot find the SubOU.
       
      Thanks for any assistance.
    • By antmar904
      I'm trying to read all cells used in column "C" in excel to an array but not sure how.
       
      Local $NameArray = _Excel_RangeRead($oWorkbook, $oWorkbook.Activesheet, $oWorkbook.Range["C"].End)  
    • By Blois
      Hey Guys,
      Good?
      I'm ned help to consult in other domain. My three domain contains any domains.
      How do I get this query done?
       
      Tks for the Help!
       
×
×
  • Create New...