Dietmar
2008-11-14 12:47:01 UTC
Hallo!
I try to use Johan Arwidmark´s Pretty Good Frontend: When a user inputs a
Computername all Active Directory OUs should be searched for this computer if
it exits to extract the distinguishedName. I added this function to Pretty
Good Frontend but it does´nt work and I really don´t know why. In Windows XP
it works great but it doesn´t in WinPE 2005:
Function ValidateAD
strName = sComputerName.Value
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Properties("User ID") = "***@domain.local"
objConnection.Properties("Password") = "password"
objConnection.Properties("Encrypt Password") = TRUE
objConnection.Properties("ADSI Flag") = 1
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = "SELECT distinguishedName FROM
'LDAP://dc=domain,dc=local' WHERE objectCategory='computer'AND Name='" &
strName & "'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
MsgBox objRecordSet.Fields("distinguishedName").Value
objRecordSet.MoveNext
Loop
On Error Resume Next
End Function
I used a whole day to search for answer in www but nothing to find. I added
ADSI support to WinPE 2005. The Pulldownmenu "Organizational Units" works
fine in WinPE 2005. Thanks Dietmar
I try to use Johan Arwidmark´s Pretty Good Frontend: When a user inputs a
Computername all Active Directory OUs should be searched for this computer if
it exits to extract the distinguishedName. I added this function to Pretty
Good Frontend but it does´nt work and I really don´t know why. In Windows XP
it works great but it doesn´t in WinPE 2005:
Function ValidateAD
strName = sComputerName.Value
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Properties("User ID") = "***@domain.local"
objConnection.Properties("Password") = "password"
objConnection.Properties("Encrypt Password") = TRUE
objConnection.Properties("ADSI Flag") = 1
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = "SELECT distinguishedName FROM
'LDAP://dc=domain,dc=local' WHERE objectCategory='computer'AND Name='" &
strName & "'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
MsgBox objRecordSet.Fields("distinguishedName").Value
objRecordSet.MoveNext
Loop
On Error Resume Next
End Function
I used a whole day to search for answer in www but nothing to find. I added
ADSI support to WinPE 2005. The Pulldownmenu "Organizational Units" works
fine in WinPE 2005. Thanks Dietmar