Please!
Jeg har fundet scriptet nedenfor, men jeg kan ikke få det til at virke... Er der virkelig ikke nogen der kan hjælpe mig?
Function GetAdsProp(ByVal SearchField As String, ByVal SearchString As String, ByVal ReturnField As String) As String
‘ Get the domain string ("dc=domain, dc=local")
Dim strDomain As String
strDomain = GetObject("
LDAP://rootDSE").Get("defaultNamingContext")
‘ ADODB Connection to AD
Dim objConnection As ADODB.Connection
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
‘ Connection
Dim objCommand As ADODB.Command
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
‘ Search the AD recursively, starting at root of the domain
objCommand.CommandText = _
"<
LDAP://" & strDomain & ">;(&(objectCategory=User)" & _
"(" & SearchField & "=" & SearchString & "));" & SearchField & "," & ReturnField & ";subtree"
‘ RecordSet
Dim objRecordSet As ADODB.Recordset
Set objRecordSet = objCommand.Execute
If objRecordSet.RecordCount = 0 Then
GetAdsProp = "not found" ‘ no records returned
Else
GetAdsProp = objRecordSet.Fields(ReturnField) ‘ return value
End If
‘ Close connection
objConnection.Close
‘ Cleanup
Set objRecordSet = Nothing
Set objCommand = Nothing
Set objConnection = Nothing
End Function