MarrowGenx
MIS
A colleague has developed the following code, but I wanted to adapt it to pull a little different information. I wanted to be able to input a directory name (instead of the user group) and get all the users who have access to that directory. An additional plus would be to also select the type of file access the users have within the directory. Here is the code:
Function GetObjectDN(strAccount)
Dim objConnection, objCommand, objRecordSet
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "SELECT AdsPath, distinguishedName, objectClass " & _
"FROM 'LDAP://DC=company,DC=com' WHERE " & _
" objectClass='group' AND " & _
" samAccountName='" & strAccount & "'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = 2 ' ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
If objRecordSet.EOF Then
GetObjectDN = ""
Else
Dim x
GetObjectDN = objRecordSet.fields("AdsPath")
End If
objConnection.Close
End Function
Any help you can provide would be much appreciated. Thanks.
Marrow
Function GetObjectDN(strAccount)
Dim objConnection, objCommand, objRecordSet
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "SELECT AdsPath, distinguishedName, objectClass " & _
"FROM 'LDAP://DC=company,DC=com' WHERE " & _
" objectClass='group' AND " & _
" samAccountName='" & strAccount & "'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = 2 ' ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
If objRecordSet.EOF Then
GetObjectDN = ""
Else
Dim x
GetObjectDN = objRecordSet.fields("AdsPath")
End If
objConnection.Close
End Function
Any help you can provide would be much appreciated. Thanks.
Marrow