Skip to content

Commit

Permalink
Change display name
Browse files Browse the repository at this point in the history
  • Loading branch information
rinkp committed Dec 22, 2020
1 parent c0b3b43 commit 10901cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def __post_request(url, json_data):
if rsp['type'] != 'success':
sys.exit(f"API {url}: {rsp['type']} - {rsp['msg']}")

def add_user(email, name, active):
def add_user(email, name, active, quotum):
password = ''.join(random.choices(string.ascii_letters + string.digits, k=20))
json_data = {
'local_part':email.split('@')[0],
'domain':email.split('@')[1],
'name':name,
'quota':"512",
'quota':str(quotum),
'password':password,
'password2':password,
"active": 1 if active else 0
Expand Down
6 changes: 3 additions & 3 deletions syncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def sync():

ldap_results = ldap_connector.search_s(config['LDAP_BASE_DN'], ldap.SCOPE_SUBTREE,
config['LDAP_FILTER'],
['mail', 'cn', 'userAccountControl'])
['mail', 'displayName', 'userAccountControl'])

ldap_results = map(lambda x: (
x[1]['mail'][0].decode(),
x[1]['cn'][0].decode(),
x[1]['displayName'][0].decode(),
False if int(x[1]['userAccountControl'][0].decode()) & 0b10 else True), ldap_results)

filedb.session_time = datetime.datetime.now()
Expand All @@ -62,7 +62,7 @@ def sync():
unchanged = False

if not api_user_exists:
api.add_user(email, ldap_name, ldap_active)
api.add_user(email, ldap_name, ldap_active, 256)
(api_user_exists, api_user_active, api_name) = (True, ldap_active, ldap_name)
logging.info (f"Added Mailcow user: {email} (Active: {ldap_active})")
unchanged = False
Expand Down

0 comments on commit 10901cb

Please sign in to comment.