views:

969

answers:

2

Using the .net 3.5 framework and C# I'm trying to add a new user to AD from C# and can't find any examples. I see that the PrincipalCollection object has an overloaded 'add' method but can't seem to figure out how it works. Can anyone help?

How create a new user object, add it into AD.

Secondly, the user that will be adding in new people may not actually have the security to do this. Is there a way that I can impersonate another user account that will have permissions and add the account that way?

+3  A: 

There's a thorough example on MSDN

Harper Shelby
I can search for 3h and not find something, finally post it here and get the correct answer in 20min... Thanks.
dilbert789
+1  A: 

You might also want to check out this excellent article Managing Directory Security Principals in the .NET 3.5 Framework by AD MVP's Ethan Wilanski and Joe Kaplan in MSDN Magazine - if you can use .NET 3.5. Highly recommended - excellent read.

Marc

marc_s
Nice article - I'll have to bookmark that one.
Harper Shelby