@@ -172,10 +172,16 @@ def compose_dn(entity):
172172 data ['rdnValue' ]= rdnValue
173173 if branchAttr != '' :
174174 branchValue = find_key (entity ,branchAttr )
175+ t = type (branchValue )
176+ if type (branchValue ) == list :
177+ branchValue = branchValue [0 ]
175178 key_branch = 'branchFor' + branchValue
176179 branch = config (key_branch ,'' )
177180 data ['branch' ]= branch
178- template_string = '{{ config.rdnattribute}}={{rdnValue}},{{ branch }},{{ config.userbase }}'
181+ if branch != '' :
182+ template_string = '{{ config.rdnattribute}}={{rdnValue}},{{ branch }},{{ config.userbase }}'
183+ else :
184+ template_string = '{{config.rdnattribute}}={{ rdnValue}},{{ config.userbase }}'
179185 else :
180186 if config ('userbase' ,'' ) != '' :
181187 template_string = '{{config.rdnattribute}}={{ rdnValue}},{{ config.userbase }}'
@@ -258,10 +264,11 @@ def upsert_entry(l,entity):
258264 rdn = get_rdn_attribure (oldDn )
259265 rdnValue = entry [rdn ][0 ].decode ('UTF-8' )
260266 new_rdn = rdn + "=" + rdnValue
267+
261268 newSuperior = dn_superior (compose_dn (entity ))
262269 try :
263270 action = "rename"
264- l .rename_s (oldDn ,new_rdn ,newSuperior )
271+ l .rename_s (oldDn ,new_rdn ,newsuperior = newSuperior )
265272 except ldap .LDAPError as e :
266273 e_dict = e .args [0 ]
267274 print (returncode (1 , 'rename ' + str (e_dict .get ("result" )) + ' ' + e_dict .get ("desc" ) + " " + e_dict .get ("info" )))
@@ -335,10 +342,11 @@ def delete_entity(l,entity):
335342 exit (1 )
336343def complete_entry (entry ,r ):
337344 for cle ,valeur in r [0 ][1 ].items ():
338- if cle .lower () != 'objectclass' :
345+ if cle .lower () != 'objectclass' and cle . lower () != 'jpegphoto' :
339346 if cle not in entry :
340347 if type (valeur ) is list :
341348 for i in valeur :
349+ w = type (i )
342350 x = i .decode ('UTF-8' )
343351 if len (x ) == 1 :
344352 v = x [0 ]
0 commit comments