[python-win32] Translating vbs GetObject("LDAP://...") to Pyt hon?

Tim Golden tim.golden at viacom-outdoor.co.uk
Tue Nov 9 16:47:10 CET 2004


[R. Alan Monroe]

| Having gotten the object "obj" in this manner, how do I work backwards
| to find out its {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} code and/or
| Something.Something class name, and list its properties?

[Preamble: not at all an expert on this kind of thing, but...]

It's not that kind of COM interface. You want to be Googling
for ADSI (something like site:msdn.microsoft.com adsi will probably
get some useful results). Having got hold of an object, you can
interrogate its schema. Something like this:

<code>

#
# These first four lines are the same
#  as the GetObject you're doing if you
#  know your active directory root
#
from win32com.client import GetObject
root = GetObject ("LDAP://rootDSE")
context = root.Get ("defaultNamingContext")
ad = GetObject ("LDAP://" + context)

#
# Get the schema (effectvely the class
#  object from which this instance derives)
#
schema = GetObject (ad.Schema)
print schema.mandatoryProperties
print schema.optionalProperties

</code>

Once again, I'd offer my active directory module, which does
some of this for you:

http://tgolden.sc.sabren.com/python/active_directory.html

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


More information about the Python-win32 mailing list