//when adding a user to a new group, we need modify the group's "member" attribute to include this user, // we cannot modify the user's "memberof" attribute public bool OnApply() { bool retVal = true; if (IsPrimaryGroupChanged) { List <LDAPMod> attrlist = new List <LDAPMod>(); //the following portion of code uses openldap "ldap_Modify_s" string basedn = _dirnode.DistinguishedName; DirectoryContext dirContext = _dirnode.LdapContext; string[] objectClass_values = null; //first obtain the current primaryGroupID value DirectoryEntry de = new DirectoryEntry(string.Format("LDAP://{0}/{1}", dirContext.DomainName, ChangedPrimaryGroup));; if (de.Properties["primaryGroupToken"].Value != null) { int iPrimaryGroupToken = Convert.ToInt32(de.Properties["primaryGroupToken"].Value.ToString()); objectClass_values = new string[] { iPrimaryGroupToken.ToString(), null }; LDAPMod attr_info = new LDAPMod((int)LDAPMod.mod_ops.LDAP_MOD_REPLACE, "primaryGroupID", objectClass_values); LDAPMod[] attrinfo = new LDAPMod[] { attr_info }; int ret = dirContext.ModifySynchronous(basedn, attrinfo); Logger.Log("Modify primaryGroupID returns " + ret); if (ret == 0) { string[] Items = UserGroupUtils.splitDn(ChangedPrimaryGroup); if (!string.IsNullOrEmpty(Items[0])) { DomainUserlabel.Text = Items[0]; } } else { retVal = false; } } } retVal = MemOfPages.OnApply_helper(MemofDnList, AddedGroups, RemovedGroups, _dirnode, this); return(retVal); }
/// <summary> /// when adding a user to a new group, we need modify the group's "member" attribute to include this user, /// we cannot modify the user's "memberof" attribute /// </summary> /// <returns></returns> public bool OnApply() { bool retVal = MemOfPages.OnApply_helper(MemofDnList, AddedGroups, RemovedGroups, _dirnode, this); return(retVal); }