[python-win32] extract and load address book from exchange

David W. Harks dave@psys.org
Sun, 6 Apr 2003 12:02:30 -0500

For our Active Directory, we pull user data out of an Oracle database and 
insert it into the AD using Python.

The process for you would be pretty straightforward -- use ADSI via 
win32com.client and do an LDAP query which returns all of the data you're 
looking to share between domains, and then update the other domains with that 
data, also using win32com.client with ADSI. I would assume you'd be able to 
just add a separate Org Unit for each sub-company and just create Contacts 
for the users on the other domains.

I strongly recommend making some sort of intermediate data type; we created a 
class called PyRecSet which is essentially a list of dictionaries containing 
a predetermined set of fields that represent our "mapping" of Oracle tables 
to AD attributes. This class also includes the ability to write out its 
contents to a .csv file for debugging purposes...it took almost no time to 
write and yet has been the most valuable debugging tool.

You should be able to use Microsoft's VBScript examples in their ADSI 
reference online to help figure out how to do the search and how to do the 
creation/updating of users; just remember that to instantiate the COM objects 
you have to call 'win32com.client.Dispatch' rather than 'Dim foo as ADsUser' 
or whatever. From there, things are pretty much the same, and you can mostly 
treat the COM objects as Python classes. (Don't forget, though, to use 
Unicode strings!)

If you need sample code, let me know and I can post some this week.

Good luck!


On Sunday 06 April 2003 12:45 am, David Orr expounded thusly:
> I am working for a company that in turn has 4+ companies within it.  They
> each have their own exchange server and I need to set up each server so
> that they have all the details (address book / global address list) from
> every other server.  I expect that I will have to set up a process that
> runs each night to update this info on each server.
> Any hints / code / links appreciated.
> David Orr
> Development Analyst Programmer
> Henry Walker Eltin
> email: david.orr@hwe.com.au
> _______________________________________________
> Python-win32 mailing list
> Python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32

David W. Harks <dave@psys.org>  http://dwblog.psys.org