Reputation: 147
How can I update active directory attributes using c#. In my case I have the following case. For every user there is a WhenCreated
attribute in AD, but what i want is, if the whenDate
is less than 30 days set the info
attribute to NEW
in active directory.
How can I do this via c# step by step.
Upvotes: 5
Views: 15942
Reputation: 40938
Use DirectoryEntry. There are lots of examples online on how to use it.
Once you have a DirectoryEntry object bound to an AD object, you can set an attribute like this:
de.Properties["info"].Value = "NEW";
de.CommitChanges();
If you need to search for object, you can use DirectorySearcher. You can see an example here, although there are plenty more online too.
Give it a try. If you run into problems, show us what you have.
Upvotes: 10