Decoding ADSI/Com errors
Dan Locks
dwlocks at cs.uchicago.edu
Wed Jun 18 18:22:44 EDT 2003
There's an ugly section in our user creation scripts that used os.popen to run the win2k comands c:>net group <groupname> <username> /add.
I decided to re-implement this with win32com and ADSI, but I'm having problems. Here's a code snippet with some traceback errors embedded:
import win32com.client
# makepy.py -i produced this ugliness for the adsi com objects
from win32com.client import gencache
gencache.EnsureModule('{97d25db0-0363-11cf-abc4-02608c9e7553}', 0, 1, 0)
user_DN = 'CN=test05,OU=studenttest,OU=YWLCS Users,DC=internal,DC=ywlcs,DC=org'
group_DN = 'LDAP://CN=resource,OU=YWLCS Users,DC=internal,DC=ywlcs,DC=org'
adsi = win32com.client.Dispatch('ADsNameSpaces')
ldap = adsi.getobject('', 'LDAP:')
# using 3 is easier than looking at
# win32com.client.constants.ADS_SECURE_AUTHENTICATION
group_obj = ldap.opendsobject(group_DN,'','',3)
# So far so good. here's where things stop working.
# Since group_obj is an IADsGroup, I should be able to use add('LDAP string')
# But I get this error:
group_obj.add( user_DN )
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "<COMObject <unknown>>", line 2, in add
com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147463168), None)
# That's pretty opaque to me.
# All ADSI objects inherit the IADs::putex method, right? maybe.
group_obj.putex(3,'member',user_DN)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "<COMObject <unknown>>", line 2, in putex
com_error: (-2147352567, 'Exception occurred.', (0, 'Active Directory', 'Unspecified error\r\n', None, 0, -2147467259), None)
# after all that this does work, but it *replaces* the group membership with
# whatever string or list of strings I send. that's not good.
group_obj.put('member',[user_DN, another_DN, ...]
group_obj.setinfo()
What do these errors mean?
How am I to decode them?
Thanks,
Dan
Technology manager, YWLCS
--
Young Women's Leadership (O__,__O/ The cure for MustSee TV:
Charter School // ,__// Lindy Hop!
-Technology Manager- >\ <
-----------------------------~-~---~-----------------------------------
More information about the Python-list
mailing list