Hi Guys,
I have 25 users in 1 AD group. i have 50 users in one of the Sql Server table. I want to compare the AD Group users with Sql table users and add to the group which do not exist in the AD group. Here is my code. Can you please modify my code?
Appreciate your help. Thanks
I have 25 users in 1 AD group. i have 50 users in one of the Sql Server table. I want to compare the AD Group users with Sql table users and add to the group which do not exist in the AD group. Here is my code. Can you please modify my code?
Appreciate your help. Thanks
VB.NET:
Dim result = adSearch.FindOne
If result IsNot Nothing Then
Dim members = result.Properties("member")
Dim sql As String
sql = "select Distingname from TEMPAD"
Dim myconn As New SqlConnection(CONNECTIONSTRING)
Dim mycommand As New SqlCommand(sql, myconn)
myconn.Open()
Dim dbreader As SqlDataReader = mycommand.ExecuteReader
For Each member In members
While dbreader.Read
If member <> dbreader("Distingname") Then
group.Properties("member").Add(dbreader("Distingname"))
group.CommitChanges()
End If
End While
Next
End If