Update active directory user from Windows Service

  • Thread starter Thread starter Adam
  • Start date Start date
A

Adam

Hi, I have a windows service that will pull data from an external
source and I need to update this informaiton in AD from a Windows
Service.

What is the easiest way to do this? I looked at using the
ActiveDirectoryMembershipProvider but it seems that this is for
ASP.NET applications only(?) or perhaps I am missing some better
results in google.

I know that I can connect via LDAP and change details using code like
the following

DirectorySearcher search = new DirectorySearcher();
search.Filter = String.Format("(SAMAccountName={0})",
userName);
search.PropertiesToLoad.Add("cn");
SearchResult result = search.FindOne();

but I was wondering if there was a better way?

Thanks for any help
Adam
 
Use LINQ2AD (Linq to active directory, this is about as easy as it gets and
you won't have to do all this tedious, error prone formatting.
 
Back
Top