Python and Active Directory

Paul Robinson paul.robinson at quantisci.co.uk
Fri Mar 10 04:41:35 EST 2000


Augustine David wrote:
> but I am unsure how to call any of its classes using
> "win32com.client.Dispatch".  Any input you can give me
> would be appreciated.
> 
> [Visual Basic]
> 
> Dim np as IADsOpenDSObject
> Dim myUser as IADs
> 
> Set np = GetObject("LDAP:")
> Set myUser = np.OpenDSObject("LDAP://CN=Bob,DC=Microsoft,DC=com",_
>                      vbNullString,vbNullString, ADS_SECURE_AUTHENTICATION)

Note that to use this code below you don't need to run makepy (apart
from for importing the constant).
This translates (I imagine - I'm assuming the Python equivalent of
vbNullString...) as:

from XX import ADS_SECURE_AUTHENTICATION #this should be available in
the makepy generated module?
import win32com.client
NS = win32com.client.Dispatch('ADSNameSpaces')
np = NS.getobject('','LDAP:')
myUser =
np.OpenDSObject('LDAP://CN=Bob,DC=Microsoft,DC=com','','',ADS_SECURE_AUTHENTICATION)

In PythonWin see the help under: Help - Other - Python COM Reference -
ADSI, Exchange, and Python
There is an example of accessing Exchange there which should help.

I've just noticed an obvious typo on both the 2nd line of the first
example and the 4th line of (non-comment) code in the second example.
myDSObject = ldapNameSpace.OpenDSObjec(ex_path,logon_ex,password,0)
Should be:
myDSObject = ldapNameSpace.OpenDSObject(ex_path,logon_ex,password,0)

Hope this helps.
	Paul.

-----------------------------------
Business Collaborator Team
Enviros Software Solutions
http://www.businesscollaborator.com
-----------------------------------




More information about the Python-list mailing list