Hallo,
ich frage unser Active Directory nach dessen Benutzerkonten ab, bzw. versuche ich das. Ich erhalte aber immer alle möglichen Objekte zurück wie z.B. GPOs, WMI-Filter, Verzeichnisfreigaben, Benutzerkonten. Seltsamerweise aber nicht alle GPOs und nicht alle WMI-Filter, bzw. Verzeichnisfreigabe, sondern nur einige. In der folgenden Zeile wird das doch normalerweise über den "objectCategory = User" entsprechend eingegrenzt. Das funktioniert aber irgendwie nicht richtig.
objCommand.CommandText = "Select Name, mail, title, samAccountName, description, homeDirectory, profilePath, badPwdCount, logonCount, lastLogonTimestamp, objectCategory FROM 'LDAP://" & Cstr(askme) & "' WHERE objectCategory='User'"
Der Rückgabewert aus objectCategory sieht so aus: CN=Person,CN=Schema,CN=Configuration,DC=X1234,DC=ADC,DC=Test,DC=DE
Hat jemand einen Tipp für mich ?
Anbei noch mein komplettes Script:
-------------------------------------------------------------
On Error Resume Next
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Dim askme As Variant
Dim ldap_name As String, ldap_mail As String, ldap_title As String, ldap_samAccountName As String, ldap_description As Variant, ldap_descriptionb As String
Dim ldap_homedir As String, ldap_profildir As String, ldap_badpwd As Variant, ldap_logoncount As Variant, ldap_lastLogon As Variant, ldap_objectCategory As Variant
askme = ws.Prompt (PROMPT_OKCANCELEDIT, "Wie heißt Ihr Domain Controller", "IP-Adresse oder WSID Ihres Domain-Controller. z.B. FS001234 oder 10.130.45.678")
If Not Isempty (askme) Then
Set db = s.CurrentDatabase
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 Name, mail, title, samAccountName, description, homeDirectory, profilePath, badPwdCount, logonCount, lastLogonTimestamp, objectCategory FROM 'LDAP://" & Cstr(askme) & "' WHERE objectCategory='User'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
ldap_name = ""
ldap_mail = ""
ldap_title = ""
ldap_samAccountName = ""
ldap_description = ""
ldap_descriptionb = ""
ldap_homedir = ""
ldap_profildir = ""
ldap_badpwd = ""
ldap_logoncount = ""
ldap_lastlogon = ""
ldap_objectCategory = ""
ldap_name = objRecordSet.Fields("name").Value
ldap_mail = objRecordSet.Fields("mail").Value
ldap_title = objRecordSet.Fields("title").Value
ldap_samAccountName = objRecordSet.Fields("samAccountName").Value
ldap_description = objRecordSet.Fields("description").Value
ldap_descriptionb = ldap_description(0)
ldap_homedir = objRecordSet.Fields("homeDirectory").Value
ldap_profildir = objRecordSet.Fields("profilePath").Value
ldap_badpwd = objRecordSet.Fields("badPwdCount").Value
ldap_logoncount = objRecordSet.Fields("logonCount").Value
ldap_lastlogon = objRecordSet.Fields("lastLogonTimestamp").Value
ldap_objectCategory = objRecordSet.Fields("objectCategory").Value
Call NeuerBenutzer(ldap_name, ldap_mail, ldap_title, ldap_samAccountName, ldap_descriptionb, ldap_homedir, ldap_profildir, ldap_badpwd, ldap_logoncount, ldap_lastlogon, ldap_objectCategory, db)
objRecordSet.MoveNext
Loop
Call ws.ViewRefresh
End If