I'm gonna build a webpart for creating user in active directory.
i want to add created user to an organizational unit if the organizational unit exist.
how i can do that?
I'm gonna build a webpart for creating user in active directory.
i want to add created user to an organizational unit if the organizational unit exist.
how i can do that?
Basically, you need to bind to the OU in question, and then call .Children.Add()
to add the new user to that OU.
See this MSDN documentation for details:
Adding Directory Objects shows how to add a group to the Users
container - you should be able to convert that to your needs
User Management with Active Directory shows sample code for exactly what you're looking for: adding a user to an organizational unit
How to do almost anything in Active Directory using C# is a great general resource showing how to do common tasks in Active Directory using C# and .NET