Sub AddUserToAGroup(ByVal GroupName As String, ByVal UserCN As String) Dim dirEntry As New DirectoryEntry dirEntry.Path = "LDAP://OU=Some_Site,DC=Domain,DC=NET" dirEntry.Username = sADUsername dirEntry.Password = sADPassword If UserExists(UserCN) = True Then Dim group As DirectoryEntry = dirEntry.Children.Find("CN=" & GroupName, "group") Dim usr As DirectoryEntry = group.Children.Find("CN=" & UserCN, "user") If group IsNot "" Then group.Properties("member").Add(usr.Properties("distinguishedName").Value) group.CommitChanges() End If ElseIf UserExists(UserCN) = False Then Exit Sub End If End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)