http://www.microsoft.com/windows2000/library/howitworks/activedirectory/adsilinks.asp

http://www.microsoft.com

rtk.htm interopt.htm ad.htm winnt.htm dev.htm ../default.htm router.gif (3874 bytes)
samples.gif (4580 bytes)
 

Samples Sorted by Development Platforms

For a complete list, please browse the ADSI samples directory.

 


Getting Started Samples

Getting started samples can be found here. The source code can be found in \\samples\start.

 


Application Samples

Some samples listed below are actually working applications.

 


Samples Sorted by Providers (or Technologies)

 


Samples that Highlight ADSI Interfaces, APIs, and Technologies

Technologies

 

Interfaces

 

APIs

 


Visual C++

 

Visual Basic

Active Server Pages

 

Perl

 


Active Directory

Samples can also be found in the samples directory and on the Active Directory page.

 

WinNT

 

Site Server

 

NDS

 

Netware

 

Netscape

 


ADsCmd

Visual C++ source code: \\samples\General\ADsCmd

This C++ sample code demonstrates how to enumerate and filter by getting a list of attributes from the schema and displaying attributes on an object.

Usage: adscmd [list|dump] <ADsPath>

Examples:

  adscmd dump WinNT://MYDOMAIN

  adscmd list LDAP://dc01/CN=Administrators, OU=Admin, DC=MyDomain, DC=Com

ADQI

Visual C++ source Code: \\samples\General\ADQI

ADQI allows you to find all of the interfaces related to ADSI that are supported for a given ADsPath. You can then use the interfaces to further manipulate the object. 

 

DsSrch

Visual C++ source code: \\samples\General\DsSrch

This code contains a command line executable which highlights the usage of IDirectorySearch, complete with the Preference option.

Usage:

dssrch /b <baseObject> /f <search_filter> [/f <attrlist>] [/p <preference>=value>] [/u <UserName> <Password>] [/t<flagName>=<value>

Where:

baseObject = ADsPath of the base of the search
search_filter = the search filter string in LDAP format
attrlist = a list of the attributes to display


Preference could be one of:

Asynchronous, AttrTypesOnly, DerefAliases, SizeLimit, TimeLimit,
TimeOut, PageSize, SearchScope, SortOn, CacheResults


FlagName could be one of:

SecureAuth or UseEncrypt

Value

Yes/no for a Boolean and the respective integer for integers.

Scope

Either "Base", "OneLevel", or "Subtree"

For Example:

dssrch /b NDS://ntmarst/ms /f "(object Class=*)" /a "ADsPath, name, description" /p searchScope=onelevel /p searchscope=onelevel


dssrch /b "LDAP://O=Internet/DC=COM/DC=MICROSOFT/DC=NTDEV" /f "(objectClass=*)" /a "ADsPath, name, usnchanged" /u

"CN=NTDS,CN=Users,DC=NTDEV,DC=MICROSOFT,DC=COM" "" /p searchScope=onelevel /t secureauth=yes /p SortOn=name /p CacheResults=no

 

ADSI Dump

Visual C++ source code: \\samples\General\ADSIDump

This application traverses a tree, visiting each object in the tree and getting the attributes on each object. All actions are recorded in a log file. Written using C++/ATL.

Usage:

ADSIDUMP ADsPath LogFile

Example:

ADSIDUMP LDAP://OU=Dev,DC=Platforms,DC=Microsoft,DC=COM ntdev.log

 

ADO Query

Visual C++ source code: \\samples\General\ADOQuery

This code demonstrates an ADO query against an LDAP provider. Only ADSI providers that support IDirectorySearch and OLE DB can work with ADO. ADSI ships two providers that are aware of OLE DB: LDAP and NDS.

 

Active Directory Windows Address Book

ASP source code: \\samples\ASP\WAB

The Windows address book searches for and displays users, groups, and contacts in Active Directory. It showcases an Active Directory search based on ambiguous name resolution (ANR). It also demonstrates an ADSI search using ADO against Active Directory.

To run the samples, first you must move the global.asa (or append the existing global.asa) to the default web site directory.

 

Active Directory: Add Group

Visual C++ source code: \\samples\activedir\addgroup\VC
Visual Basic source code: \\samples\activedir\addgroup\VB

This sample adds a Windows 2000 group under a container. The group can either be a security or a distribution list type. Other options for the group type are universal, global and domain local groups.

 

Active Directory: Attributes

Visual C++ source code: \\samples\activedir\attributes\VC
Visual Basic source code: \\samples\activedir\attributes\VB

This sample demonstrates how to find attributes by indexed value, GC replication, and type.

 

Active Directory: Bind To Parent

Visual C++ source code: \\samples\activedir\bindtoparent\VC
Visual Basic source code: \\samples\activedir\bindtoparent\VB

This program finds a user and displays the user's container.

 

Active Directory: Computer

Visual Basic source code: \\samples\activedir\computer

This sample creates a machine account under the Active Directory computer container. You may create a machine under an organizational unit. This program requires you to specify a machine account.  By default (using the GPO-Group Policy Objects) in the Windows 2000 domain, every authenticated user is able to create a machine account.

 

Active Directory: Create User

Visual C++ source code: \\samples\activedir\createuser\VC
Visual Basic source code: \\samples\activedir\createuser\VB

This sample creates a user under a specified container. It requires that you specify the user's relative distinguished name and downlevel name.

 

Active Directory: Credentials

Visual C++ source code: \\samples\activedir\credentials\VC
Visual Basic source code: \\samples\activedir\credentials\VB

This sample allows you to log on to the current domain with alternate credentials.

 

Active Directory: Find All Users in Global Catalog

Visual C++ source code: \\samples\activedir\gcallusers\VC
Visual Basic source code: \\samples\activedir\gcallusers\VB


The
global catalog contains all objects in the enterprise. Only selected attributes are replicated it.  This sample shows you how to connect to the global catalog with ADSI using the IDirectorySearch interface.

 

Active Directory: Get Domain Mode

Visual C++ source code: \\samples\activedir\getdomainmode
Visual Basic source code: \\samples\activedir\getdomainmode

This sample checks whether Active Directory is in mixed or native mode.

 

Active Directory: Schema Info

Visual C++ source code: \\samples\ActiveDir\GetSchemaInfo
Visual Basic source code: \\samples\ActiveDir\GetSchemaInfo

This program queries the schema for the specified classes or attributes.

 

Active Directory: GUID Binding

Visual C++ source code: \\samples\ActiveDir\GUIDBinding
Visual Basic source code: \\samples\ActiveDir\GUIDBinding

Active Directory allows you to bind object by its GUID. This sample demonstrates binding to a GUID.

 

Active Directory: Well Known GUID

Visual C++ source code: \\samples\ActiveDir\WKGUID
Visual Basic source code: \\samples\ActiveDir\WKGUID

Active Directory has the concept of well known GUIDs. This is a well known place, normally a container, which is associated to a well known GUID. 

 

Active Directory: Property List

Visual C++ source code: \\samples\ActiveDir\PropertyList
Visual Basic source code: \\samples\ActiveDir\PropertyList

This code demonstrates the use of PropertyList in Active Directory.

 

Active Directory: Query Users

Visual C++ source code: \\samples\ActiveDir\QueryUsers
Visual Basic source code: \\samples\ActiveDir\QueryUsers

This sample finds a user in the current domain.

 

Active Directory: RootDSE

Visual C++ source code: \\samples\ActiveDir\RootDSE
Visual Basic source code: \\samples\ActiveDir\RootDSE

This sample gets the RootDSE on a server and prints out the entries.

 

IADsExtension

C++ Source code: \\samples\Extension\Tutorial\Step2

This is a step-by-step tutorial on how to create an ADSI extension. The first step is to create an early binding extension without implementing IADsExtension. The second step implements the IADsExtension to support late binding.

This extension will extend a 'user' object on the LDAP provider. You can easily change it to other provider by modifying the DLL Registration code. You can use this source code as a code base for your extension.

This sample code accompanies with the client code written in VB.

 

Active Directory User

Visual C++ source code: \\samples\ActiveDir\User

This program finds a user in the current Window 2000 domain, and displays its IADsUser properties.

 

Active Directory Other WellKnown Object

Visual C++ source code: \\samples\ActiveDir\OtherWKO\VC
Visual Basic source code: \\samples\ActiveDir\OtherWKO\VB

This program does the following:

  1. Creates a container (MyWKOTestContainer) in the current Windows 2000 domain.
  2. Creates a container object (MyWKOTestObject) within the container.
  3. Adds a value for the container object on the otherWellKnownObject property of the container.
  4. Binds to the container object using the WKGUID binding string.
  5. Renames the container object using the WKGUID binding string.
  6. Binds to the container object using the WKGUID binding string.
  7. Optionally, cleans up by removing the container and container object.

Active Directory SID

Visual C++ source code: \\samples\ActiveDir\SID\VC
Visual Basic source code: \\samples\ActiveDir\SID\VB

This program finds a user in the current Windows 2000 domain
and displays its objectSid property in string form.
This program demonstrates how to read a property of type octet string.

 

WinNT Binding

Visual Basic source code: \\samples\WinNT\Binding\VB

This code snippet illustrates how to bind to a domain, remote computer, or a user in a domain. It also shows how to bind an object with alternate credentials.

 

WinNT Group

Visual Basic source code: \\samples\WinNT\Group\VB

This sample is a walkthrough for managing a group life cycle, from the creation and enumeration of the group (both local and global), to the addition and removal of users and groups to the group.

 

WinNT Computer

Visual Basic source code: \\samples\WinNT\Computer\VB

This sample demonstrates how to bind to a computer object, enumerate services, sessions, and resources, and create a file share.

 

WinNT User

Visual Basic source code: \\samples\WinNT\User\VB

This sample demonstrates how to create a user, set a user's properties, and rename and delete a user.

 

WinNT User Management

Visual Basic source code: \\samples\WinNT\UsrMgr

This sample is a WinNT User Management Application.

 

WinNT Change Password

Visual Basic source code: \\samples\WinNT\ChangePwd

This application is used to change the Windows NT password. The user is required to enter an old and new password.  You can change your domain password or your local account password.

 

WinNT Print Queue

Visual Basic source code: \\samples\WinNT\PrintQueue (short version),  \\samples\WinNT\PrintQueue\App (long version)

This code shows print queues for a given computer. 

 

WinNT Reset Password

Visual Basic source code: \\samples\WinNT\ResetPwd

This sample resets the user's password. The caller must have administrative privileges. 

Perl: Binding

Perl source code: \\samples\Perl

Perl: Creating and Deleting an Object

Perl source code: \\samples\Perl

Perl: Retrieving and Modifying Properties

Perl source code: \\samples\Perl

 

ADSI Provider

C++ source code: \\samples\Provider

The following is the installation procedure for the Active DS Sample Provider:

  1. Install ADSI.
  2. Install the Sample Provider using install.bat found in \\samples\provider\setup.

You will need to run install.bat to install the Sample Provider and set up the sample directory service in the registry.

To view the sample provider:

  1. Run ADSVW.EXE.
  2. Type Sample: as the ADsPath.
  3. You can now navigate the name space.