Using System.DirectoryServices to update specific LDAP attribute
Wondering if anyone knows when you are trying to add a user to a group in an LDAP if there is a way to add the member into the uniquemember attribute instead of member attribute. My code to add a member to a group using System.DirectoryServices is below but it adds the member to the group using the member attribute. We want to try and add user into the uniquemember attribute. I am trying to use the System.DirectoryServices namespace in the .Net 1.1 Framework and using invoke command interoping over to ADSI to use the add command. Anybody know any other way that can add a user via the uniquemember attribute?
htLDAP = AppSettings.GetLDAPConnectionString
mstrLDAPPwd =
Me.GetLDAPPasswordmstrLDAPName = htLDAP("LDAP")
strLDAPOU = htLDAP("LDAPOU")
strGroupOU = AppSettings.GetLDAPGroupOU
Dim objRootAs DirectoryEntry =New DirectoryEntry("LDAP://" & mstrLDAPName & _"/" & strGroupOU)
objRoot.Username = htLDAP("LDAPUserName")
objRoot.Password = mstrLDAPPwd
Dim objSearcherAs DirectorySearcher =New DirectorySearcher(objRoot)objSearcher.Filter = "(cn=" & strGroupName & ")"
Dim grpSearchAs SearchResult = objSearcher.FindOne()Dim grpAs DirectoryEntry =New DirectoryEntry(grpSearch.Path, htLDAP("LDAPUserName"), mstrLDAPPwd, AuthenticationTypes.Delegation)Dim objUserAsNew DirectoryEntry("LDAP://" & mstrLDAPName & _"/uid=" & strUid & "," & strLDAPOU, htLDAP("LDAPUserName"), mstrLDAPPwd)
Dim blnIsMemberAsBoolean = Convert.ToBoolean(grp.Invoke("IsMember",NewObject() {objUser.Path}))If blnIsMemberThenReturnFalseElsegrp.Invoke("Add",
NewObject() {objUser.Path})grp.CommitChanges()
ReturnTrueEndIfCatch exAs ExceptionstrError = ex.Message()
ReturnFalseEndTry
