public void ShouldUpdateUser() { var user = new UpdateADuser { DN = _dn }; var attributes = new List <EntryAttribute> { new EntryAttribute { Attribute = AdUserAttribute.description, Value = "MattiMeikalainen", DataType = AttributeType.String } }; user.OtherAttributes = attributes.ToArray(); var result = LdapActiveDirectoryOperations.AD_UpdateUser(_connection, user); Assert.AreEqual(result.operationSuccessful, true); }
public DirectoryEntry UpdateAdUser(UpdateADuser user) { //if (!user.CN.ToUpper().StartsWith("CN=")) // user.CN = "CN=" + user.CN; var entry = FindPath(_rootEntry, user.DN); var entryAttributes = GetEntryAttributes(user, user.OtherAttributes); SetDirectoryEntryAttributes(entry, entryAttributes, true); foreach (var flag in user.ADFlags) { entry.SetAccountFlag(flag.FlagType, flag.Value); } SaveEntry(entry); return(entry); }
/// <summary> /// Update a user in the AD. /// </summary> /// <param name="ldapConnectionInfo">The LDAP connection information</param> /// <param name="adUser">The user record to be updated</param> /// <returns>LdapResult class, which carries a copy of the updated user record.</returns> public static OutputUser AD_UpdateUser([PropertyTab] LdapConnectionInfo ldapConnectionInfo, [PropertyTab] UpdateADuser adUser) { var ldapOperationResult = new OutputUser { operationSuccessful = false, user = null }; using (var ldap = new LdapService(ldapConnectionInfo)) { ldapOperationResult.user = ldap.UpdateAdUser(adUser); ldapOperationResult.operationSuccessful = true; return(ldapOperationResult); } }