Public
Database()
Public
ADPath
As
String
Public
ADName
As
String
Public
Function
OrgaRead(ObjectTyp
As
String
, Deep
As
String
,
Optional
ADFeld
As
String
,
Optional
What
As
String
,
Optional
Root
As
Boolean
)
Erase
Database
If
ADFeld =
""
Then
ADFeld =
"name"
If
What =
""
Then
What =
"name"
If
ADName =
""
Then
ADName =
"*"
strDNSDomain = objRootDSE.
Get
(
"defaultNamingContext"
)
If
Root =
False
Then
strBase =
"<LDAP://"
& ADPath &
"OU=BA,"
& strDNSDomain &
">"
Else
strBase =
"<LDAP://"
& strDNSDomain &
">"
End
If
Set
adoCommand = CreateObject(
"ADODB.Command"
)
Set
ADOConnection = CreateObject(
"ADODB.Connection"
)
ADOConnection.Provider =
"ADsDSOObject"
ADOConnection.Open
"Active Directory Provider"
adoCommand.ActiveConnection = ADOConnection
strFilter =
"(&(objectClass="
& ObjectTyp &
")("
& ADFeld &
"="
& ADName &
"));"
& What &
";"
& Deep
strQuery = strBase &
";"
& strFilter
adoCommand.CommandText = strQuery
adoCommand.Properties(
"Page Size"
) = 1000
adoCommand.Properties(
"Timeout"
) = 30
adoCommand.Properties(
"Cache Results"
) =
False
adoCommand.Properties(
"Sort on"
) = ADFeld
Set
adoRecordset = adoCommand.Execute
If
Not
adoRecordset.BOF
Then
Database = adoRecordset.GetRows
End
Function