I'm trying to create an Active Directory Synchronization function in Access, similar to that found in Project Server 2007. I can enumerate all the members of my AD group with the following code:
Sub ADMembers()
Dim strSql As String
Dim LoginName As Object, tblEmployees As Table
Dim adsGroup As IADsGroup, adsMembers As IADsMembers
Dim varItem As Object
Set adsGroup = GetObject("WinNT://MYDOMAIN/MYADGROUP")
Set adsMembers = adsGroup.Members
For Each varItem In adsMembers
Debug.Print varItem.Name
Next varItem
End Sub
What I need to do next is to compare each varItem.Name to the values in the LoginName field in tblEmployees. If there is a match, do nothing (the employee is already in the table). If there is no match, create a new record in tblEmployees with the value of varItem.Name inserted into the LoginName field.
What is the best way to accomplish this task? (Sorry if this question has been asked and answered before, but I did a few searches and didn't find what I needed.)
Sub ADMembers()
Dim strSql As String
Dim LoginName As Object, tblEmployees As Table
Dim adsGroup As IADsGroup, adsMembers As IADsMembers
Dim varItem As Object
Set adsGroup = GetObject("WinNT://MYDOMAIN/MYADGROUP")
Set adsMembers = adsGroup.Members
For Each varItem In adsMembers
Debug.Print varItem.Name
Next varItem
End Sub
What I need to do next is to compare each varItem.Name to the values in the LoginName field in tblEmployees. If there is a match, do nothing (the employee is already in the table). If there is no match, create a new record in tblEmployees with the value of varItem.Name inserted into the LoginName field.
What is the best way to accomplish this task? (Sorry if this question has been asked and answered before, but I did a few searches and didn't find what I needed.)