banner.gif (5982 bytes)

mslogo.gif (666 bytes)

router.gif (3874 bytes)

samples.gif (4580 bytes)
 

Samples Sorted by Development Platforms

For complete list, please browse the ADSI samples directory.


Getting Started Samples

Getting Started Samples can be found in here. The source codes can be found in samples/start.

 


Application Samples

Some samples listed below is actually working applications.


Samples Sorted by Providers ( or Technologies )

 


Samples Highlighting ADSI Interfaces, APIs, and Technologies

Technologies

Interfaces

APIs

 


Visual C++

Visual Basic

Visual Basic Script

Active Server Page

Perl

 


Active Directory

Samples can also be found in the sample directory and Active Directory Page.

 

WinNT

Exchange

Site Server

NDS

Netware

Netscape

 


ADsCmd
Source code: samples\general\adscmd

A C++ sample code demonstrates Enumerator and Filtering 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
Source Code: samples\general\adqi

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

DsSrch
Source code: samples\general\dssrch

A command line executable, highlighting IDirectorySearch usage 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 = search filter string in LDAP format
attrlist = 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
Source code: samples\general\adsidump

An application that traverse a tree, visit each object in a 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
Source code: samples\general\adoquery

It demonstrates ADO Query against LDAP provider. Only ADSI providers that support IDirectorySearch and OLE DB can work with ADO. ADSI 2.5 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 and displays users, groups, and contacts in Active Directory. It showcases the Active Directory search based on ambigious name resolution (ANR). It also demonstrates 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

Add Windows 2000 Group under a container. The group can be security or distribution list type, other option is the group type for Universal, Global and Domain Local groups.

Active Directory: Attributes
Visual C++ source code:samples/ActiveDir/Attributes

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

Active Directory: Bind To Parent
Visual C++ source code:samples/ActiveDir/BindToParent

This program find a user and display the user's container.

Active Directory: Computer
Visual Basic source code:samples/ActiveDir/Computer

Creating a user under a specified container. It requires to specify the user's Relative Distinguished Name and Downlevel Name.

Active Directory: Create User
Visual C++ source code:samples/ActiveDir/CreateUser

Creating a user under a specified container. It requires to specify the user's Relative Distinguished Name and Downlevel Name.

Active Directory: Credentials
Visual C++ source code:samples/ActiveDir/Credentials

Logon to the current domain with the alternate credentials.

Active Directory: GC All Users
Visual C++ source code:samples/ActiveDir/GCAllUsers

Searching a user in the forest by searching the Global Catalog.

Active Directory: Get Domain Mode
Visual C++ source code:samples/ActiveDir/GetDomainMode

The sample checks if Active Directory is in mixed or native mode.

Active Directory: Schema Info
Visual C++ source code:samples/ActiveDir/GetSchemaInfo

This program queries schema for the specified classes or attributes.

Active Directory: Guid Binding
Visual C++ source code:samples/ActiveDir/GUIDBinding

Active Directory allows you to bind object by GUID. This sample demonstrates it.

Active Directory: Well Known Guid
Visual C++ source code:samples/ActiveDir/WKGUID

Active Directory has a concept of Well Known GUID. It's a well known place, normally a container, which is associated with a well known GUID. 

Active Directory: Property List
Visual C++ source code:samples/ActiveDir/PropertyList

It demonstrate the use of PropertyList in Active Directory.

Active Directory: Query Users
Visual C++ source code:samples/ActiveDir/QueryUsers

Finding a user in the current domain.

Active Directory: RootDSE
Visual C++ source code:samples/ActiveDir/RootDSE

Get the RootDSE on a server and print 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.

 

Mailbox
VB source code: samples\Exchange\Mailbox

It demonstrate how to create an Exchange Mailbox using Visual Basic. It uses many Win32 APIs to manipulate the security descriptor and SID.  Alternatively, you can use the ADSI Resource Tool Kit to create a mailbox.

 

Rule-Based Distribution List
VB source code: samples\Exchange\RDBL

RBDL.EXE will automatically populate and update Microsoft Exchange "rules based distribution lists". The membership in a "rules based distribution list" is determined by criteria based upon Exchange directory attributes. RBDL.EXE determines which distribution lists to modify and the precise membership of the distribution list based upon a criteria string that is stored within the DL itself. This functionality allows RBDL.EXE to populate and keep up to date DLs like the following:

"All mailboxes in California" or
"All mailboxes on ServerX" or
"All people in the Sales Department that are not Temporary Employees".

Since RBDL.EXE uses LDAP v3 to update the directory, at least one Exchange 5.5 server per organization is required.

Run the distribution list with the following command line parameter "/container:"LDAP://server/o=organization/ou=site/cn=Recipients"

Exchange Tombstone
VB source code: samples\Exchange\Tombstone

It shows how to retrieve a tombstone (deleted) object on Exchange Server 5.5

 

Exchange Configuration
VB source code: samples\Exchange\Configuration

It shows you how to modify Exchange Configuration attributes, such as set the maximum value of message size on an Exchange Server.

 

Exchange Search Alias (VBS)
VBS source code: samples\Exchange\SearchAlias\SearchAlias.vbs
Usage: cscript searchAlias.vbs aliasName

Given a alias name, this script will search the alias object for a given Exchange Server name.

Exchange Distribution List
VB source code: samples\Exchange\Distribution List

This sample demonstrates how to:

  • Create a new distribution list
  • Add a member to a distribution list
  • Enumerate a member in a distribution list
  • Set the owner of distribution list
  • Set permission of a distribution list

 

Getting Home-MDB of a Mailbox
VB source code: samples\Exchange\HomeMDB

For a given mailbox, this sample demonstrates how to instantiate its HomeMDB object.

 

Retrieving Objects Based on USN-Change
VB source code: samples\Exchange\USNChange

Exchange uses USNChange for replication purposes. Now you can try it yourself to find out which objects were changed since last replication (you need to know the USNChange value).

 

Creating a Custom Recipient
VB source code: samples\Exchange\Custom Recipient

Create a new recipient object in a container. Set the new recipient's attributes such as telephoneNumber, target-address, cn, and so on.

 

Enumerating an Exchange Container
VB source code: samples\Exchange\Enum

It enumerates a container and list and categorize persons, custom recipients and distribution lists in that container.

 

Finding Exchange Organization Name for a Given Server
VB source code: samples\Exchange\Org

It demonstrates how to get an Exchange organization name if you know the Exchange Server name.

 

Displaying and Modifying Exchange Security Descriptor
VB source code: samples\Exchange\Security

It shows how to get and set the Exchange security descriptor using IADsPropertyValue2.
Requirements: Exchange 5.5 SP1 and ADSI 2.5.

 

WinNT Binding
VB 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
VB source code: samples\WinNT\Group\vb

Walkthrough Group life cycle management, from group creation (local and global), group enumeration, adding user/group to a group and removing members.

WinNT Computer
VB source code: samples\WinNT\Computer\vb

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

WinNT User
VB 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

VB source code: samples\WinNT\User\vb

A WinNt User Management Application.

 

WinNT Change Password
VB source code: samples\WinNT\ChangePwd


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.

 

Perl: Binding
Perl source code: samples\Perl\binding.pl

 

Perl: Create and Delete Object
Perl source code: samples\Perl\create.pl

 

Perl: Retrieve and Modify Properties
Perl source code: samples\Perl\modify.pl

 

ADSI Provider
C++ source code: samples\Provider

Installation procedure for the Active DS Sample Provider:
1)Install ADSI 2.5
2)Install the Sample Provider using install.bat found in samples\provider\setup

Running install.bat will perform the following:
1)Install Sample Provider
2)Setup the sample DS in the registry

To view the sample provider
1) Run ADSVW.EXE
2) Type Sample: as the ADsPath
3) Now you can navigate the name space