[python-win32] Creating an Exchange mailbox for an Active Dir ectory user

Suzuki Alex Alex.Suzuki at ksta.ktzh.ch
Fri Sep 2 13:15:35 CEST 2005


Hi Rudy.

The code below creates a user in the active directory and
then creates an Exchange mailbox. You need to install CDOEXM
on your client machine.

I didn't realize you could just call IMailBoxStore::CreateMailBox
like that. I guess this has to do with some magic behind IDispatch.
Again, I am totally new to COM, and actually hope to be done with it
as soon as possible.

The string you pass to CreateMailBox is a distinguished name that
identifies the Information store in which you want to create the
user's mailbox. Its format is (I think):

cn=[StoreName],cn=[Storage group],cn=InformationStore,cn=[Server name],\
cn=Servers,cn=[Administrative group],cn=Exchange,cn=Microsoft Exchange,\
cn=Services,cn=Configuration,[Domain components]

You can browse your active directory with adsiedit to find out the
string for your installation.

cheers,
  Alex

-->--
import win32com, win32com.client, pythoncom

path = "LDAP://hostname/cn=Users,dc=kt,dc=ktzh,dc=ch"
auth = (binddn, bindpw)

# Get ADSI Namespace object
ns = win32com.client.Dispatch("ADsNameSpaces")

# Get LDAP provider
ldap = ns.GetObject("", "LDAP:")

cont = ldap.OpenDSObject(path, auth[0], auth[1], 0)

ou = cont.Create("organizationalUnit", "ou=Sandbox")
ou.SetInfo()

jolie = ou.Create("user", "cn=jolie")
jolie.Put("sAMAccountName", "jolie")
jolie.Put("userPrincipalName", "jolie at domain.com")
jolie.Put("sn", "Jolie")
jolie.Put("givenName", "Angelina")
jolie.Put("description", "Sandbox user")
jolie.Put("mail", "angelina.jolie at domain.com")
jolie.SetInfo()

jolie.AccountDisabled = 0
jolie.SetInfo()

jolie.CreateMailBox("CN=Postfachspeicher (W2K03GE01),CN=Erste
Speichergruppe,CN=InformationStore,CN=W2K03GE01,CN=Servers,CN=Erste
administrative Gruppe,CN=Administrative Groups,CN=Exchange,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=kt,DC=ktzh,DC=ch")
jolie.SetInfo()
--<--


-----Original Message-----
From: Rudy Schockaert [mailto:rudy.schockaert at gmail.com]
Sent: Friday, September 02, 2005 11:59 AM
To: Suzuki Alex
Cc: python-win32 at python.org
Subject: Re: [python-win32] Creating an Exchange mailbox for an Active Dir
ectory user


Alex,

do you mind sharing your experience. I think others (including me) are
interested in this.

Ciao,

Rudy


On 9/2/05, Suzuki Alex < Alex.Suzuki at ksta.ktzh.ch> wrote:
> I'm trying to create an Exchange mailbox for an existing user in the 
> Active Directory.

Never mind, I figured it out.

cheers, A.
_______________________________________________
Python-win32 mailing list
Python-win32 at python.org 
http://mail.python.org/mailman/listinfo/python-win32




-- 
"A little nonsense now and then, is cherished by the wisest men."  -- Roald
Dahl 


More information about the Python-win32 mailing list