ClulessChris
IS-IT--Management
Can anybody suggest a method to find a users OU?
Everybody body is somebodys Nutter.
Everybody body is somebodys Nutter.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sub GetUsersFromAD()
Dim lRow As Long
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT DN FROM 'LDAP://dc=corphq,dc=co,dc=uk' WHERE samAccountName='UserIDGoesHere' "
Set objRecordset = objCommand.Execute