tuxMuc Posted March 22, 2008 Posted March 22, 2008 Hi all, it's possible to ask for 'accountExpires' with ADFunctions? If yes, how? My script works, but the point 'accountExpires' is empty. GUICreate("BLA - ", 320, 180) $GUILabelSnr = GUICtrlCreateLabel("S-Nummer", 30, 33) $GUIInputWhois = GUICtrlCreateInput("", 30, 50, 50) GUICtrlSetLimit(-1, 7) $GUIButtonSearch = GUICtrlCreateButton("1", 35, 100, 40, 40, $BS_ICON) GUICtrlSetImage (-1, @ScriptDir & "\icons\Search.ico") $GUIGroup = GUICtrlCreateGroup("Info:", 130, 20, 150, 130) $GUIName = GUICtrlCreateLabel("", 140, 53, 130) $GUIStandort = GUICtrlCreateLabel("", 140, 71, 130) $GUITelefon = GUICtrlCreateLabel("", 140, 89, 130) $GUIMobil = GUICtrlCreateLabel("", 140, 107, 130) $GUIAblauf = GUICtrlCreateLabel("", 140, 125, 130) Func _SearchAD() $object = GUICtrlRead($GUIInputWhois) If $object = "" Then $object = @UserName $Name = _ADGetObjectAttribute($object, "cn") $Company = _ADGetObjectAttribute($object, "company") $Telefon = _ADGetObjectAttribute($object, "telephonenumber") $Mobil = _ADGetObjectAttribute($object, "mobile") $Ablauf = _ADGetObjectAttribute($object, "accountExpires") I don't understand this, because the ldap name is 'accountExpires'. Thx for help tux
secman Posted June 6, 2008 Posted June 6, 2008 Hi all,it's possible to ask for 'accountExpires' with ADFunctions?If yes, how?My script works, but the point 'accountExpires' is empty.GUICreate("BLA - ", 320, 180)$GUILabelSnr = GUICtrlCreateLabel("S-Nummer", 30, 33)$GUIInputWhois = GUICtrlCreateInput("", 30, 50, 50)GUICtrlSetLimit(-1, 7)$GUIButtonSearch = GUICtrlCreateButton("1", 35, 100, 40, 40, $BS_ICON)GUICtrlSetImage (-1, @ScriptDir & "\icons\Search.ico")$GUIGroup = GUICtrlCreateGroup("Info:", 130, 20, 150, 130)$GUIName = GUICtrlCreateLabel("", 140, 53, 130)$GUIStandort = GUICtrlCreateLabel("", 140, 71, 130)$GUITelefon = GUICtrlCreateLabel("", 140, 89, 130)$GUIMobil = GUICtrlCreateLabel("", 140, 107, 130)$GUIAblauf = GUICtrlCreateLabel("", 140, 125, 130)Func _SearchAD() $object = GUICtrlRead($GUIInputWhois) If $object = "" Then $object = @UserName $Name = _ADGetObjectAttribute($object, "cn") $Company = _ADGetObjectAttribute($object, "company") $Telefon = _ADGetObjectAttribute($object, "telephonenumber") $Mobil = _ADGetObjectAttribute($object, "mobile") $Ablauf = _ADGetObjectAttribute($object, "accountExpires")I don't understand this, because the ldap name is 'accountExpires'. Thx for helptuxI am new to AUTOIT but would like to use a small part of your code to extract a users full name from the AD. Would you mind posting the whole program so that I can see how the functions and, for example _ADGetObjectAttribute macro(?) is created.Many thanksAlan
gulthaw Posted June 6, 2008 Posted June 6, 2008 This code was found in the forums and adapted to my needs Local $objCommand = ObjCreate("ADODB.Command") Local $objConnection = ObjCreate("ADODB.Connection") $strComputer = @ComputerName $user = @UserName $objConnection.Provider = "ADsDSOObject" $objConnection.Open ("Active Directory Provider") $objCommand.ActiveConnection = $objConnection Local $strBase = "<LDAP://dc=DOMAIN_NAME,dc=COM>" Local $strFilter = "(&(objectCategory=person)(objectClass=user)(sAMAccountName="&$user&"))" ; here you shall put the AD parameter you need Local $strAttributes = "cn,sAMAccountName,displayName,sn,distinguishedName,co,ADSPath" Local $strQuery = $strBase & ";" & $strFilter & ";" & $strAttributes & ";subtree" $objCommand.CommandText = $strQuery $objCommand.Properties ("Page Size") = 100 $objCommand.Properties ("Timeout") = 30 $objCommand.Properties ("Cache Results") = False $ADS_SCOPE_SUBTREE = 2 $objCommand.Properties ("searchscope") = $ADS_SCOPE_SUBTREE $objRecordSet = $objCommand.Execute ; here we catch the country, sample sintax to get the parameters $co = $objRecordSet.Fields("co").valueThe $strAttributes variable is where you have to add every AD parameter you want to see.For example, if you want the street you have to add ",street" to $strAttributes and add $street = $objRecordSet.Fields("street").valueto the end.Check http://www.winzero.ca/Active-Directory-users.htm for a list of parameters and how are they called.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now