Usings ADSI to Access Exchange - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Usings ADSI to Access Exchange

Description:

Simplified and uniform manipulation of DS objects in a heterogeneous environment ... When you know the object name. GetObject(ADsPath) From Java, Visual Basic, ... – PowerPoint PPT presentation

Number of Views:104
Avg rating:3.0/5.0
Slides: 36
Provided by: tomr69
Category:

less

Transcript and Presenter's Notes

Title: Usings ADSI to Access Exchange


1
Using ADSI To Access The Exchange 5.5
Directory Tom Rizzo Thomriz_at_microsoft.comMicroso
ft Corporation
2
(No Transcript)
3
Agenda
  • Overview of ADSI architecture
  • Programming with ADSI
  • Binding to a DS object
  • Reading and writing properties
  • Searching
  • Creating new Mailboxes
  • Demonstrations
  • Questions

4
Introduction To Active Directory Service
Interfaces
  • ADSI is the Microsoft strategic API to the
    Active Directory
  • Windows 2000 Active Directory supports ADSI
  • Simplified and uniform manipulation of DS objects
    in a heterogeneous environment
  • Ease of use for cross-language development
  • Visual Basic, Java, Visual C, Visual C

5
ADSI ArchitectureLeaf component object
  • IADs
  • Dual-interface
  • On all ADSI objects
  • Name and class
  • Path and link to parent
  • Link to schema
  • Property caching
  • IADsUser
  • User-specific properties
  • IDispatch
  • Name-bound access

E.g., user object
IADs
IADsOU
IDispatch
6
ADSI ArchitectureContainer component object
  • IADsContainer
  • Dual-interface
  • Found on allDS containers
  • Enumeration
  • Life cycle (Create, Delete, CopyHere, MoveHere)

E.g., organizational unit object
IADs
IADsOU
IADsContainer
IDispatch
7
Viewing Exchange Schema
  • Run Exchange in Raw Mode
  • Select View.Raw Directory

8
Other Tools For ADSI
  • You can also use ADSI Browser or LDP to view
    Exchange schema
  • Schema is super important
  • Access-Category is important as well
  • 0 System only
  • 1 Modify Admin Attributes
  • 2 Modify User Attributes
  • 3 Modify Permissions
  • Eg. Phone number is Access-Category 2

9
Common Object Classes
  • Mail-Recipient (person)
  • Mailbox (organizationalPerson)
  • Custom-Recipient (custom-recipient)
  • Distribution-List (groupOfNames)

Object class names are modifiable using Exchange
Admin in raw mode
10
Doing Useful Work With ADSI
  • You need
  • A supported programming language like Java,
    Visual Basic, Visual C, Visual C
  • An interface pointer to IADs
  • And away you go!

11
Programming With ADSIIADs
  • Implemented by every base object
  • Properties
  • Name, ADsPath, class, schema, parent
  • Methods
  • Get, put, getinfo, setinfo
  • Using only the IADs interface you can learn all
    about an object and get or set all of its
    properties

12
Getting An Interface PointerWhen you know the
object name
  • GetObject(ADsPath)
  • From Java, Visual Basic, Visual Basic for
    Applications, Visual Basic Scripting Edition
  • ADsGetObject(ADsPath,riid,pObj)
  • From Visual C, Visual C, etc.
  • ADs pathltprovidergt//ltprovider-specific-stringgt
  • For example LDAP//ServerAddress/CUS/OMicroso
    ft/OUAccounting/CNJamesSmith

13
Getting Objects
  • OpenDSObject(Path, username, password,
    authentication)
  • Make sure that the path is a valid path
  • Username should be in the format cnUsername
  • To get hidden items/PFs, add cnadmin to the end
    of your username

14
Binding An Object
  • Example 1Binding a DS object, reading and
    writing properties using LDAP

15
Reading AndWriting Properties
  • Simple caching system
  • IADsGetInfo()
  • Reloads the cache with values from the
    underlying store
  • Changes made in the cache are lost
  • IADsSetInfo()
  • Writes cached changesto the underlying store

16
What About Individual Props?
  • Use Put and Get for simple properties
  • For multi-value properties, you need to use GetEx
    and PutEx
  • After setting properties, always call SetInfo!

17
Binding To An ObjectVisual Basic code snippet
Set objADsExchDL _ GetObject("LDAP//MR53CPU1/cn
SampleDL,cn" _ Recipients,ouMR53,oMicrosoft")
MsgBox "Owner " objADsExchDL.Owner
18
Reading Properties Visual Basic code snippet
strPathADsExchConfig _ "LDAP//MR53CPU1/cnMicro
soft Private MDB," _ "cnWashington,cnServers,
" _ "cnConfiguration,ouEurope,oTailspin
Toys " Set objADsExchConfig _ GetObject(strPath
ADsExchConfig) objADsExchConfig.GetInfo strConfig
Mail objADsExchConfig.Get("mail")
19
Writing Properties Visual Basic code snippet
Set objADsExchRecipients _ GetObject("LDAP//Was
hinton/" _ "cnRecipients,ouEurope,oTailspin
Toys") Set objADsExchDL _ objADsExchRecipients
.Create _ ("groupOfNames", "cn"
CStr(pstrAlias)) ' Set properties objADsExchDL.P
ut "cn", CStr(pstrDispName) objADsExchDL.Put
"uid", CStr(pstrAlias)
20
Manipulating Objects
  • Example 2
  • Simple object manipulationCreatingDeleting

21
Manipulating Objects
Dim MyContainer As IADsContainer Bind to
container object Set MyContainer
_ GetObject("LDAP//MyLdapSvr/OInternet" _
"/DCRedmond") Create a child object MyChildObjec
t MyContainer.Create _ ("User",
"CNMyUser") Set mandatory properties
MyChildObject.Put("samAccountName", "MyUser")
Commit the child object MyChildObject.SetInfo N
ow delete the child object MyContainer.Delete("Use
r", "CNMyUser")
22
Object Enumeration
  • Example 3Discovering a container and
    recursively enumerating the contents

23
Enumerating A Container Visual Basic code snippet
Private Sub cmdEnum_Click() Dim MyContainer As
IADsContainer 'Bind to container object Set
MyContainer GetObject("LDAP//Washington/ouEuro
pe" _ ",oTailspin Toys") 'Enumerate child
objects For Each Object In MyContainer
Debug.Print Object.ADsPath Next End Sub
24
Searching The Directory
  • Example 4Searching the Exchange Directory via
    ADSI

25
Searching The Directory Visual Basic ADO script
Set conn CreateObject("ADODB.Connection") conn.O
pen "ProviderADSDSOObject Set rsSel
conn.Execute(strQuery) ADS_cSel
rsSel.RecordCount While Not rsSel.EOF For i 0
To rsSel.Fields.Count - 1 Debug.Print
CStr(rsSel.Fields(I)) Next i
rsSel.MoveNext Wend
26
Querying A Directory
strQuery "ltLDAP//Washington/cnRecipients,ouEru
ope,_ "oTailspin Toysgt" _ "((cnM)(!(objectC
lassgroupOfNames)))"_ "cn,adspath,uidOneLevel"
  • The root node of a search
  • String that specifies criteria
  • Identifies attributes of interest
  • Beginning entry point, Base, OneLevel or SubTree
  • Base DN ltLDAP
  • Filter ((cnM)
  • Property List cn,adspath,uid
  • Scope OneLevel

27
Create Mailboxes
  • Use ADSI to
  • Create the mailbox
  • Use AcctCrtlibrary to
  • Associate NT account
  • Set permissions on mailbox

28
GAL Modify Example
29
GAL Modify Example Find user
Set ADOconn CreateObject("ADODB.Connection") ADO
conn.Provider "ADSDSOObject" ADOconn.Open "ADs
Provider" bstrADOQueryString "ltLDAP//"
bstrServer _ "gt((objectClassorganizationalPer
son)" _ "(cn" bstrSearchCriteria "))"
_ "cn,adspathsubtree" Set objRS _
ADOconn.Execute(bstrADOQueryString)
30
GAL Modify Example Modify data
Sub ModifyProperty (bstrNewValue,
bstrADsProperty) If Len(bstrNewValue) ltgt 0
Then objIADs.Put bstrADsProperty,
CStr(bstrNewValue) Else objIADs.Get(bstrADsP
roperty) If Err.Number 0 Then
objIADs.PutEx ADS_PROPERTY_CLEAR,_ bstrADsPropert
y, CStr(" ") End If Err.Clear End
If End Sub
31
Update DL Example
  • Add
  • Modify
  • Delete

32
Summary
  • Benefits of ADSI
  • Easy to write Directory Service-enabled
    applications!
  • Single API for many namespaces
  • Cross-language support
  • Reduced development cost
  • Single set of management applications
  • Reduced learning curve

33
Summary
  • Prepare for the Window 2000 Active Directory by
    using the Exchange 5.5 directory and ADSI today
  • ADSI provides simple, uniform directory object
    manipulation in a heterogeneous environment

34
Additional Resources
  • http//msdn.microsoft.com/exchange
  • Http//www.microsoft.com/exchange
  • http//www.microsoft.com/windows/server/Technical/
    directory/default.asp
  • http//www.microsoft.com/windows/server/Technical/
    directory/adsilinks.asp
  • Programming Microsoft Outlook and Exchange
    (MSPRESS)

35
Questions?
36
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com