Created
March 10, 2017 01:38
-
-
Save adamdriscoll/d59af1e6e0f89973b868c2b64f100e77 to your computer and use it in GitHub Desktop.
Set attribute LDAP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var connectionObject = new LdapConnection(new LdapDirectoryIdentifier(controller), new NetworkCredential(username, password)); | |
var directoryAttributeModification = new DirectoryAttributeModification(); | |
directoryAttributeModification.Name = attribute; | |
directoryAttributeModification.Operation = DirectoryAttributeOperation.Replace; | |
foreach (var value in values) | |
{ | |
if (value is byte[]) | |
{ | |
directoryAttributeModification.Add(value as byte[]); | |
} | |
else | |
{ | |
directoryAttributeModification.Add(value.ToString()); | |
} | |
} | |
var response = connectionObject.SendRequest(new ModifyRequest | |
{ | |
DistinguishedName = dn, | |
Modifications = | |
{ | |
directoryAttributeModification | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment