Ramya_mudambi
Registered User.
- Local time
- Today, 16:24
- Joined
- Dec 27, 2013
- Messages
- 32
Dear all,
As a beginner with Access, I have spent a lot of time searching this issue but cannot find an answer that works... So I am hoping that by posting my request, your great minds will definitely help me out...!!!!
This is Really Really URGENT - From MS Access, I'm trying to Retrieve USERS from Active Directory Group.
Good news is I'm successful in connecting to the Active directory and retrieve the values for Attributes "Name", "ObjectCategory"
Note: Attributes "Name", "ObjectCategory" - are fields that contain records ONLY in single row.
Where am i Struck:
When i try to extract LIST OF USERS present in "MEMBER" attribute, the system throws "Type Mismatch" error in line - rs!member = objrecordset.Fields("member").Value.
* Resources say, the "member" attribute is a multi-value attribute that contains the list of distinguished names for the user, group, and contact objects that are members of the group
With my limited knowledge, I don't know how to get this field into Access
With your expertise on Active Directory to Access, Request you to kindly help me update the code (below) to extract values in "member" attribute.
Attached is the snapshot (.jpg) from the Active Directory.
Eager to hear from you. SOMEONE PLEASE Shower SOME MERCY AND HELP ME !!
Eager to hear more from you.
Many Thanks,
Ramya
==============================
Option Compare Database
Private Sub Command1_Click()
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
UsrName = InputBox("Enter Domain\UserID:")
Pswd = InputBox("Enter Password:")
oConnection1.Properties("User ID") = UsrName
oConnection1.Properties("Password") = Pswd
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
Dim rs As ADODB.Recordset
Dim strSQL As String
objCommand.CommandText = _
"SELECT Name, objectCategory, member FROM 'LDAP://<IPaddress>:<Port#>' WHERE name='Domain Admins'"
Set objrecordset = objCommand.Execute
If objrecordset.EOF And objrecordset.BOF Then
MsgBox "No records found."
objrecordset.Close
Exit Sub
End If
objrecordset.MoveFirst
strSQL = "Select * from Users_In_ADGroup"
Do While Not objrecordset.EOF
Set rs = New ADODB.Recordset
rs.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
Debug.Print rs.Fields("Name")
rs.AddNew
rs!ADGroup = objrecordset.Fields("Name").Value
rs!objectCategory = objrecordset.Fields("objectCategory").Value
rs!member = objrecordset.Fields("member").Value
rs.Update
rs.Close
Set rs = Nothing
End Sub
As a beginner with Access, I have spent a lot of time searching this issue but cannot find an answer that works... So I am hoping that by posting my request, your great minds will definitely help me out...!!!!
This is Really Really URGENT - From MS Access, I'm trying to Retrieve USERS from Active Directory Group.
Good news is I'm successful in connecting to the Active directory and retrieve the values for Attributes "Name", "ObjectCategory"
Note: Attributes "Name", "ObjectCategory" - are fields that contain records ONLY in single row.
Where am i Struck:
When i try to extract LIST OF USERS present in "MEMBER" attribute, the system throws "Type Mismatch" error in line - rs!member = objrecordset.Fields("member").Value.
* Resources say, the "member" attribute is a multi-value attribute that contains the list of distinguished names for the user, group, and contact objects that are members of the group
With my limited knowledge, I don't know how to get this field into Access
With your expertise on Active Directory to Access, Request you to kindly help me update the code (below) to extract values in "member" attribute.
Attached is the snapshot (.jpg) from the Active Directory.
Eager to hear from you. SOMEONE PLEASE Shower SOME MERCY AND HELP ME !!
Eager to hear more from you.
Many Thanks,
Ramya
==============================
Option Compare Database
Private Sub Command1_Click()
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
UsrName = InputBox("Enter Domain\UserID:")
Pswd = InputBox("Enter Password:")
oConnection1.Properties("User ID") = UsrName
oConnection1.Properties("Password") = Pswd
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
Dim rs As ADODB.Recordset
Dim strSQL As String
objCommand.CommandText = _
"SELECT Name, objectCategory, member FROM 'LDAP://<IPaddress>:<Port#>' WHERE name='Domain Admins'"
Set objrecordset = objCommand.Execute
If objrecordset.EOF And objrecordset.BOF Then
MsgBox "No records found."
objrecordset.Close
Exit Sub
End If
objrecordset.MoveFirst
strSQL = "Select * from Users_In_ADGroup"
Do While Not objrecordset.EOF
Set rs = New ADODB.Recordset
rs.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
Debug.Print rs.Fields("Name")
rs.AddNew
rs!ADGroup = objrecordset.Fields("Name").Value
rs!objectCategory = objrecordset.Fields("objectCategory").Value
rs!member = objrecordset.Fields("member").Value
rs.Update
rs.Close
Set rs = Nothing
End Sub