Directory Services

Getting Started with ASP for ADSI

ADSI can be used to access directory data using an ASP page. This can be a convenient way to run administration tasks and queries from a Web page or provide information to employees on an intranet. One advantage of using ADSI with ASP is that you can create a richer user experience because you can use Visual Basic to create an ADSI application and offer it to a user through a standard Web page. For example, you could create a Web page that enables employees to enter the last name of an employee and get back a phone number for that employee, or create a form that allows employees to update personal information in a company human resources database.

ASP code starts with '<%' and ends with '%>'. You can add ADSI code as VBScript or Visual Basic.

To create an ASP page, you can use a Web page editor, Notepad or other text editor, or Microsoft® Visual Studio .NET.

Before you run your ASP page, set up your application or IIS server according to the instructions found in Authentication Issues for ADSI with ASP.

A Simple ASP Sample: Enumerating Objects on a Computer

Using a Web page editor, create a new html page which accepts a computer, user name and password. For example, Default.htm. Enter the following code example.

<form method="POST" action="enum.asp">
<p>Connect to:<input type="text" name="Computer" size="20"></p>
<p>User Name:<input type="text" name="username" size="20"></p>
<p>Password:<input type="text" name="password" size="20"></p>

This page can now accept a computer name that is passed to it and use ADSI to enumerate objects on the computer.

Create a new ASP page called Enum.asp and enter the following code example.

' Get the inputs.
compName = Request.Form("computer")
usrName	= Request.Form("userName")
password   = Request.Form("password")

' Bind to the object.
adsPath = "LDAP://" & compName & ",computer"
Set dso = GetObject("LDAP:")
Set comp = dso.OpenDSObject(adsPath, userName, password,)

IIS ADSI Provider

IIS server contains an ADSI provider which you can use and extend programmatically to add automated tasks to the IIS server for the purpose of Web site administration. For more information about using ADSI for IIS administration, see Using ADSI to Manage IIS and the accompanying IIS ADSI Provider Reference. For more information about extending the IIS ADSI schema, see ADSI Extensibility.