Skip to content

Commit 51cd81b

Browse files
committed
corrections
1 parent 1205422 commit 51cd81b

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/lib/ad_utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ def compose_dn(entity):
5252
if branchAttr != '':
5353
branchValue=u.find_key(entity,branchAttr)
5454
key_branch='branchFor' + branchValue
55-
branch=u.config(key_branch,'')
56-
data['branch']=branch
57-
template_string = 'cn={{ rdnValue}},{{ branch }},{{ config.base }}'
55+
if branchValue != '':
56+
branch=u.config(key_branch,'')
57+
data['branch']=branch
58+
template_string = 'cn={{ rdnValue}},{{ branch }},{{ config.base }}'
59+
else:
60+
template_string = 'cn={{ rdnValue}},{{ config.base }}'
5861
else:
5962
template_string= 'cn={{ rdnValue}},{{ config.base }}'
6063
template = jinja2.Environment(loader=jinja2.BaseLoader()).from_string(u.config('dnTemplate',template_string))

src/lib/backend_utils.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,23 @@ def _finditem(obj, key):
5959
item = _finditem(v, key)
6060
if item is not None:
6161
return item
62-
62+
return ""
6363
def make_entry_array(entity):
6464
data={}
6565
if "identity" in entity['payload']:
6666
objectclasses = entity['payload']['identity']['identity']['additionalFields']['objectClasses']
6767
inetOrgPerson=entity['payload']['identity']['identity']['inetOrgPerson']
68-
additionalFields=entity['payload']['identity']['identity']['additionalFields']['attributes']
69-
68+
if 'attributes' in entity['payload']['identity']['identity']['additionalFields']:
69+
additionalFields=entity['payload']['identity']['identity']['additionalFields']['attributes']
70+
else:
71+
additionalFields = {}
7072
else:
7173
objectclasses=entity['payload']['additionalFields']['objectClasses']
7274
inetOrgPerson = entity['payload']['inetOrgPerson']
73-
additionalFields = entity['payload']['additionalFields']['attributes']
75+
if 'attributes' in entity['payload']['additionalFields']:
76+
additionalFields = entity['payload']['additionalFields']['attributes']
77+
else:
78+
additionalFields = {}
7479
#inetOrgPerson
7580
for k,v in inetOrgPerson.items():
7681
data[k]=str(v)

0 commit comments

Comments
 (0)