G
Guest
Have to write a VB program to get the main domain AD User Information,process
and Auth.
But this program not in the main AD domain.
Already check some documents to write the connection parameter , but it
never work.
The Code is bellow: But the error happen in "oCmd.Execute"
The Error Message is "The Data Table is not exist"
The code run in domain is ok.
===========================================
Dim oRootDSE, oCon, oCmd, oRecordSet
Dim sDomainADsPath, sUser, sPassword, sGroup, sProperties
Dim aDescription, aMember, iCount, intUAC
On Error GoTo ErrorHandle
sDomainADsPath = "LDAP://DC=" & Replace(tDomain.Text, ".", ",DC=")
Set oCon = CreateObject("ADODB.Connection")
'oCon.Provider = "ADsDSOObject"
oCon.Open "Provider=ADSDSOObject;User Id=ABC;Password=XXX;"
Set oCmd = CreateObject("ADODB.Command")
Set oCmd.ActiveConnection = oCon
DOMAIN = "LDAP://dc=" & tDomain.Text & ", dc=domainextension"
sql = "select cn,distinguishedname from '" + sDomainADsPath + "' where
objectclass='" + tAccount.Text + "' and objectclass<>'computer'"
oCmd.CommandText = sql
Set oRecordSet = oCmd.Execute
sProperties =
"name,ADsPath,description,member,sAMAccountName,DisplayName,EmployeeID,userAccountControl,mail,distinguishedName"
sProperties = sProperties &
",givenName,legacyExchangeDN,physicalDeliveryOfficeName,proxyAddresses,sn,birthLocation"
sProperties = sProperties &
",userPassword,unicodePwd,userPrincipalName,accountNameHistory"
If Trim(tAccount.Text) <> "" Then
sGroup = tAccount.Text
Else
sGroup = "*"
End If
oCmd.CommandText = "<" & sDomainADsPath &
">;(&(objectCategory=user)(sAMAccountName=" & sGroup & "));" & sProperties &
";subtree"
oCmd.Properties("Page Size") = 100
Set oRecordSet = oCmd.Execute
===========================================
I don't know is it suitable to post this question here,
but pls comment how it work out. Thanks
and Auth.
But this program not in the main AD domain.
Already check some documents to write the connection parameter , but it
never work.
The Code is bellow: But the error happen in "oCmd.Execute"
The Error Message is "The Data Table is not exist"
The code run in domain is ok.
===========================================
Dim oRootDSE, oCon, oCmd, oRecordSet
Dim sDomainADsPath, sUser, sPassword, sGroup, sProperties
Dim aDescription, aMember, iCount, intUAC
On Error GoTo ErrorHandle
sDomainADsPath = "LDAP://DC=" & Replace(tDomain.Text, ".", ",DC=")
Set oCon = CreateObject("ADODB.Connection")
'oCon.Provider = "ADsDSOObject"
oCon.Open "Provider=ADSDSOObject;User Id=ABC;Password=XXX;"
Set oCmd = CreateObject("ADODB.Command")
Set oCmd.ActiveConnection = oCon
DOMAIN = "LDAP://dc=" & tDomain.Text & ", dc=domainextension"
sql = "select cn,distinguishedname from '" + sDomainADsPath + "' where
objectclass='" + tAccount.Text + "' and objectclass<>'computer'"
oCmd.CommandText = sql
Set oRecordSet = oCmd.Execute
sProperties =
"name,ADsPath,description,member,sAMAccountName,DisplayName,EmployeeID,userAccountControl,mail,distinguishedName"
sProperties = sProperties &
",givenName,legacyExchangeDN,physicalDeliveryOfficeName,proxyAddresses,sn,birthLocation"
sProperties = sProperties &
",userPassword,unicodePwd,userPrincipalName,accountNameHistory"
If Trim(tAccount.Text) <> "" Then
sGroup = tAccount.Text
Else
sGroup = "*"
End If
oCmd.CommandText = "<" & sDomainADsPath &
">;(&(objectCategory=user)(sAMAccountName=" & sGroup & "));" & sProperties &
";subtree"
oCmd.Properties("Page Size") = 100
Set oRecordSet = oCmd.Execute
===========================================
I don't know is it suitable to post this question here,
but pls comment how it work out. Thanks