Updating the Active Directory User Properties using C# or VB .Net
The LdapUser object contains properties and methods that pertain to Active Directory users. Those properties can be updated then saved back to Active Directory using the Save function.
Langauges Supported
ASP.NET, C#, VB.Net, Visual Studio 2010, Visual Sutdio 2008
Method: Save
Parameters: (string) Username
Precondition
A valid LdapUser object
Functionality
The method is called passing the Username as a string. Three
things can then occur:
- If the username exists and the method returns true.
- If the username does not exist the
method returns false
- An Exception will be thrown for other errors
Example
Where LdapConnection is an instance of LdapManager
LdapUser oUser = myLDAP.GetUser(UserProperty.Username, "Michael");
oUser.Properties["streetaddress"] = "7733 Hollywood Blvd";
oUser.Properties["l"] = "Beverley Hills";
oUser.Properties["st"] = "CA";
oUser.Properties["postalcode"] = "92010";
oUser.Properties["co"] = "USA";
oUser.Properties["manager"] = myLDAP.GetUser(UserProperty.Username, "larry").DistinguishedName;;
oUser.Save();
Post Condition
The Active Directory is updated by the save
|