.NET Active Directory Wrapper    
Access Active Directory From Your C# or VB .Net Code
 

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 2012

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:

  1. If the username exists and the method returns true.
  2. If the username does not exist the method returns false
  3. 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