#NEWLINE# def ldap_moniker( root = None , server = None , username = None , password = None ) : #NEWLINE# #INDENT# if ( root is None ) : #NEWLINE# #INDENT# root = adsi . ADsOpenObject ( ldap_moniker ( 'rootDSE' , server ) , username , password , ( ( adsicon . ADS_SECURE_AUTHENTICATION | adsicon . ADS_SERVER_BIND ) | adsicon . ADS_FAST_BIND ) , adsi . IID_IADs ) . Get ( 'defaultNamingContext' ) #NEWLINE# #UNINDENT# ( prefix , rest ) = re . match ( '(\\w+://)?(.*)' , root ) . groups ( ) #NEWLINE# if ( not prefix ) : #NEWLINE# #INDENT# prefix = 'LDAP://' #NEWLINE# #UNINDENT# if server : #NEWLINE# #INDENT# return ( '%s%s/%s' % ( prefix , server , root ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( '%s%s' % ( root , root ) )