Function Reference

_AD_GetObjectOU

Returns the OU (Organizational Unit) of an object ("user", "group" etc.).

#Include <AD.au3>
_AD_GetObjectOU($sObject[, $sReturn = "distinguishedName"])

 

Parameters

$sObject Object for which the main class should be returned. Can be specified as Fully Qualified Domain Name (FQDN), sAMAccountName or ADsPath
$sReturn Optional: Property to return. Must be "distinguishedName" or "Name" (default = "distinguishedName")

 

Return Value

Success: FQDN of the object's OU.
Failure: "", sets @error to:
    1 - Specified object does not exist
    2 - The LDAP query returned no record. @extended is set to the error returned by LDAP
    3 - Parameter $sReturn is wrong. Must be "distinguishedName" or "Name"

 

Remarks

None.

 

Related

 

Example


#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
; *****************************************************************************
; Example 1
; Displays FQDN and OU of the current user and local computer.
; *****************************************************************************
#include <AD.au3>

; Open Connection to the Active Directory
_AD_Open()
If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)

; Return class for the logged on user and local computer
MsgBox(64, "Active Directory Functions - Example 1", _
        "Logged on user: " & @CRLF & "  FQDN: " & _AD_GetObjectAttribute(@UserName, "distinguishedname") & @CRLF & "  OU: " & _AD_GetObjectOU(@UserName) & @CRLF & _
        "Local computer: " & @CRLF & "  FQDN: " & _AD_GetObjectAttribute(@ComputerName & "$", "distinguishedname") & @CRLF & "  OU: " & _AD_GetObjectOU(@ComputerName & "$"))

; Close Connection to the Active Directory
_AD_Close()