How to use the library

May 2, 2008 at 4:13 PM
How to use the ADHelper Library
All functions are accessed through the HelperFuntions Class, this is the only class you will need to use to get started.

LDAP Configuration

Accessing the directory can be configured in many ways through the constructor of the Helperfunction Class.

1. No configuration
Creating a new helperfunction object with no parameters will instanitate an object using the machines domain and the process user name and password, and all the limitations that go with it. This method requires you to create the object at runtime if you required more than the default machine values.

2. Configuration stored in the web.config
The default constructor will attempt to read it's configuration from a custom section in the web.config file. To use this functionality, add the following lines to your web.config.

<section name="ADHelperConfig" type="ADHelper.DirectoryHelper.ADHelperConfig" requirePermission="false" />

<ADHelperConfig AD_Host="[address or hostname of the AD server"
AD_Root="Domain Root" // ex: DC=Domain,DC=Local
AD_User="LDAP distinguished user name" // ex: CN=Administrator,CN=Users,DC=Domain,DC=Local
AD_Password="password for user">
<add CategoryName="Default" URL="~/ADHelper/Images/folder.jpg" />
<add CategoryName="Person" URL="~/ADHelper/Images/person.jpg" />
<add CategoryName="Computer" URL="~/ADHelper/Images/computer.jpg" />
<add CategoryName="Printer" URL="~/ADHelper/Images/printer.jpg" />
<add CategoryName="Group" URL="~/ADHelper/Images/group.jpg" />

In the above example, the ImageURLs are used by the GetObjectTree Function. Each objects record has a field for an ImageURL, which will be populated based on it's 'objectCategory' in the Active Directory according to this configuration. This can also be done at runtime by creating a CategoryImageCollection and assigning it to the ImageURLs property of the Helperfunction Class.

This method allows you to consume the objects at design time using any VS object; Gridview, Detailsview, Treeview, etc... via an objectdatasource.

3. At runtime
Two other contructors exist for the Helperfunction class.
- new(byval Host as string, byval Root as string)
Build a new object, configuring LDAP to use the specified server and root, with the security of the machine account.
- new(byval host as string, byval Root as string, byval user as string, byval password as string)
Build a new object, configuring LDaP completely at runtime.

Jul 8, 2008 at 5:32 AM
Edited Jul 8, 2008 at 5:33 AM
good job !

can you give us examples ?