S
Stefan 'Birdie' Vogel
Hello,
I need to run a query agains a 2003-ActiveDirectory using LDAP.
It works fine for the domain I'm logged in, but I need to run it agains a
different domain in our forrest.
Just want to avoid to login to each of our domains for running the script.
strField = "distinguishedName"
'Create ADO connection object for Active Directory
Set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"
'Create ADO command object for the connection.
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConn
'Get the ADsPath for the domain to search.
Set objRoot = GetObject("LDAP://rootDSE")
strDomain = objRoot.Get("defaultNamingContext")
Set objDomain = GetObject("LDAP://" & strDomain)
strSQL = "SELECT " & strField & " FROM '"
strSQL = strSQL & "LDAP://" & strDomain & "' WHERE samaccountname = '" &
Shortname & "'"
Regards
Stefan
I need to run a query agains a 2003-ActiveDirectory using LDAP.
It works fine for the domain I'm logged in, but I need to run it agains a
different domain in our forrest.
Just want to avoid to login to each of our domains for running the script.
strField = "distinguishedName"
'Create ADO connection object for Active Directory
Set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"
'Create ADO command object for the connection.
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConn
'Get the ADsPath for the domain to search.
Set objRoot = GetObject("LDAP://rootDSE")
strDomain = objRoot.Get("defaultNamingContext")
Set objDomain = GetObject("LDAP://" & strDomain)
strSQL = "SELECT " & strField & " FROM '"
strSQL = strSQL & "LDAP://" & strDomain & "' WHERE samaccountname = '" &
Shortname & "'"
Regards
Stefan