Radsam Posted October 3, 2005 Share Posted October 3, 2005 Has anyone got a successful A3 script at searching for a user in the GAL and pulling their data? Thanks, Radsam Link to comment Share on other sites More sharing options...
theguy0000 Posted October 3, 2005 Share Posted October 3, 2005 GAL? The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
DaleHohm Posted October 3, 2005 Share Posted October 3, 2005 GAL = Global Address Listbut most people wouldn't know that unless they worked in a corporate Exchange environment.I have not done a single user lookup, but I have enumerated a distribution list using ADSI and LDAP (and COM in the AutoIt beta). It is really very simple, but getting the syntax of the LDAP attributes right is a bear.It will be something like:$user = ObjGet("LDAP://catalog-server/CN='lastname, firstname',OU=users,OU=Accounts,DC=foo,DC=bar,DC=baz")If you get the syntax right, $user will have the properties that you are looking for (e.g. .distinguishedname etc.)Sorry I can't be more specific, but I haven't done exactly what you want. Try a few things, do some looking in MSDN and report back on your progress.DaleHas anyone got a successful A3 script at searching for a user in the GAL and pulling their data?Thanks,Radsam Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
drak Posted October 3, 2005 Share Posted October 3, 2005 (edited) here's a working Example of how to get the computers from AD, this may or may not point you in the right direction $ADS_SCOPE_SUBTREE = 2 $objConnection = ObjCreate("ADODB.Connection") $objCommand = ObjCreate("ADODB.Command") $objConnection.Provider = "ADsDSOObject" $objConnection.Open "Active Directory Provider" $objCommand.ActiveConnection = $objConnection $objCommand.CommandText = "Select Name, Location from 'LDAP://DC=an,DC=world,DC=net' Where objectClass='computer'" $objCommand.Properties("Page Size") = 1000 $objCommand.Properties("Searchscope") = $ADS_SCOPE_SUBTREE $objRecordSet = $objCommand.Execute $objRecordSet.MoveFirst Do MsgBox(4096, "Workstation/Server", $objRecordSet.Fields("Name").Value) $objRecordSet.MoveNext Until $objRecordSet.EOF Edit: If you use ScriTE to run this you will get some errors but you can ignore them & continue Edited October 3, 2005 by drak Link to comment Share on other sites More sharing options...
DaleHohm Posted October 3, 2005 Share Posted October 3, 2005 If you're trying to return a singleton you don't need to fuss with ADODB and create a recordset. You really can do it with the single line with the ObjGet... again getting the LDAP attributes set properly for your implementation is the tricky part. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
drak Posted October 3, 2005 Share Posted October 3, 2005 as Dale say's if you know what you are looking for then it is just 1 line of code for those that don't then this may help, just supply the user id also change $sCompanyDomain to your domain the main work is done in the Func, it will return the full qualified user id then you can use it to do the rest of what you want expandcollapse popup#include <GUIConstants.au3> $STYLE1 = BitOR(0x00080000, 0x00C00000, 0x00020000) $sCompanyDomain = "dc=an,dc=world,dc=net" $HWND = GUICreate("User ID", 400, 190, -1, -1, $STYLE1) AutoItSetOption("GUIResizeMode", 1) $ReturnValueDis = GUICtrlCreateLabel("", 30, 10, 300, 20) GUICtrlCreateLabel("User ID:", 30, 35) $userid = GUICtrlCreateInput("", 70, 35) $OK = GUICtrlCreateButton("Ok", 30, 160, 75, 20) $CANCEL = GUICtrlCreateButton("Cancel", 180, 160, 75, 20) GuiSetState () While 1 $MSG = GUIGetMsg() if ($msg = $GUI_EVENT_CLOSE) or ($msg = $CANCEL) Then Exit EndIf If $msg = $OK Then If guictrlread($USERID) = "" Then GUICtrlSetData($ReturnValueDis, "No User ID") ContinueLoop EndIf $CompleteOU = FindOUforUser(guictrlread($USERID)) if $CompleteOU = "User Not Found" then GUICtrlSetData($ReturnValueDis, "User Doesn't exist in domain") Else GUICtrlSetData($ReturnValueDis, $CompleteOU) EndIf EndIf Wend Func FindOUforUser($sValue) Dim $objRecordSet, $objCommand, $objConnection $ADS_SCOPE_SUBTREE = 2 $objConnection = ObjCreate("ADODB.Connection") $objCommand = ObjCreate("ADODB.Command") $objConnection.Provider = "ADsDSOObject" $objConnection.Open("Active Directory Provider") $objCommand.ActiveConnection = $objConnection $objCommand.CommandText = "SELECT distinguishedName FROM 'LDAP://" & $sCompanyDomain & "' WHERE objectCategory='user' AND sAMAccountName='" & $sValue & "'" $objRecordSet = $objCommand.Execute $objRecordSet.MoveFirst If @error <> 0 Then Return "User Not Found" Else Return $objRecordSet.Fields("distinguishedName").Value EndIf EndFunc 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