Radsam Posted March 13, 2007 Share Posted March 13, 2007 I was unable to find anything in the forums regarding my issue. I need to search AD to see if the "displayName" object exists. I already have the code to find if the "sAMAccountName" exists. Ultimately, I need to have a script that allows me to search with EITHER "displayName" or "sAMAccountName" and display the object details. Below is what I have for just the "sAMAccountName": Local $sUserName = "Lastname, Firstname ABC:DE";our display names are formatted as shown. Local $ADS_NAME_INITTYPE_GC = 3 Local $ADS_NAME_TYPE_NT4 = 3 Local $ADS_NAME_TYPE_1779 = 1 Local $sMemberOf = "" Local $objRootDSE = ObjGet ("LDAP://RootDSE") If @error Or $sUserName = "" Then MsgBox(0, 'Error', 'Username does not exist or not able to communicate with ' & @LogonDomain) Exit Else $objTrans = ObjCreate ("NameTranslate") $objTrans.Init ($ADS_NAME_INITTYPE_GC, "") ;~ $objTrans.Set ($ADS_NAME_TYPE_1779, @LogonDomain) $objTrans.Set ($ADS_NAME_TYPE_NT4, @LogonDomain & "\" & $sUserName) $strUserDN = $objTrans.Get ($ADS_NAME_TYPE_1779) $UserObj = ObjGet ("LDAP://" & $strUserDN) If @error Then MsgBox(0, 'Error', 'Username does not exist or not able to communicate with ' & @LogonDomain) Exit EndIf EndIf ;Output object details... ConsoleWrite($UserObj.displayName) ConsoleWrite($UserObj.scriptPath) ConsoleWrite($UserObj.HomeDirectory) Link to comment Share on other sites More sharing options...
EndFunc Posted March 13, 2007 Share Posted March 13, 2007 (edited) I was unable to find anything in the forums regarding my issue. I need to search AD to see if the "displayName" object exists. I already have the code to find if the "sAMAccountName" exists. Ultimately, I need to have a script that allows me to search with EITHER "displayName" or "sAMAccountName" and display the object details. Below is what I have for just the "sAMAccountName": Local $sUserName = "Lastname, Firstname ABC:DE";our display names are formatted as shown. Local $ADS_NAME_INITTYPE_GC = 3 Local $ADS_NAME_TYPE_NT4 = 3 Local $ADS_NAME_TYPE_1779 = 1 Local $sMemberOf = "" Local $objRootDSE = ObjGet ("LDAP://RootDSE") If @error Or $sUserName = "" Then MsgBox(0, 'Error', 'Username does not exist or not able to communicate with ' & @LogonDomain) Exit Else $objTrans = ObjCreate ("NameTranslate") $objTrans.Init ($ADS_NAME_INITTYPE_GC, "") ;~ $objTrans.Set ($ADS_NAME_TYPE_1779, @LogonDomain) $objTrans.Set ($ADS_NAME_TYPE_NT4, @LogonDomain & "\" & $sUserName) $strUserDN = $objTrans.Get ($ADS_NAME_TYPE_1779) $UserObj = ObjGet ("LDAP://" & $strUserDN) If @error Then MsgBox(0, 'Error', 'Username does not exist or not able to communicate with ' & @LogonDomain) Exit EndIf EndIf ;Output object details... ConsoleWrite($UserObj.displayName) ConsoleWrite($UserObj.scriptPath) ConsoleWrite($UserObj.HomeDirectory) Try using the _ADDNToDisplayName() for the display name in AD. If you don't have the adfunctions.au3 then you can get it here it has many AD functions you can use. http://www.autoitscript.com/forum/index.ph...st&p=294788 Hope this helps. Edit: Or you can probably use _ADOUObjectNames() Edited March 13, 2007 by EndFunc EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
Radsam Posted March 20, 2007 Author Share Posted March 20, 2007 Can someone please provide example? I need to be able to search AD with either a "displayName" or "sAMAccountName". The idea is a user will type into an input field either of the above names and click a search button. The rest of my script finds either the "displayName" or "sAMAccountName" in AD and returns various attributes of the object. I know how to search AD with the "sAMAccountName", but can someone give me an example of how to do so with the "displayName". Link to comment Share on other sites More sharing options...
Radsam Posted March 20, 2007 Author Share Posted March 20, 2007 bump Link to comment Share on other sites More sharing options...
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