added api for update name
This commit is contained in:
@@ -190,7 +190,7 @@ for ldapUser in ldapUsers:
|
|||||||
logger.error("There was an error setting user {0} to active in Seafile".format(ldapUser.mail))
|
logger.error("There was an error setting user {0} to active in Seafile".format(ldapUser.mail))
|
||||||
# user is not in the SQL table
|
# user is not in the SQL table
|
||||||
else:
|
else:
|
||||||
logger.debug("LDAP User {0} is NOT in the SQL Table".format(ldapUser.mail))
|
logger.info("LDAP User {0} is NOT in the SQL Table".format(ldapUser.mail))
|
||||||
# add user to ldap table
|
# add user to ldap table
|
||||||
cnx = mysql.connector.connect(**dbconfig)
|
cnx = mysql.connector.connect(**dbconfig)
|
||||||
cursor = cnx.cursor()
|
cursor = cnx.cursor()
|
||||||
@@ -200,7 +200,14 @@ for ldapUser in ldapUsers:
|
|||||||
cnx.commit()
|
cnx.commit()
|
||||||
row_count = cursor.rowcount
|
row_count = cursor.rowcount
|
||||||
if row_count == 1:
|
if row_count == 1:
|
||||||
logger.debug("LDAP user {0} was added to the SQL Table".format(ldapUser.mail))
|
logger.info("LDAP user {0} was added to the SQL Table".format(ldapUser.mail))
|
||||||
|
# need to update the name correctly as it only shows the first part of the email address as the name
|
||||||
|
# call the api to enable the user in seafile
|
||||||
|
updateSeafileUserName = request('admin/users/{0}/'.format(ldapUser.mail), seafileURL, seafileToken, "PUT", {"name": "{0} {1}".format(ldapUser.givenName, ldapUser.sn)})['response']
|
||||||
|
#if updateSeafileUserName['is_active']:
|
||||||
|
# logger.info("User {0} was set to active in Seafile".format(ldapUser.mail))
|
||||||
|
#else:
|
||||||
|
# logger.error("There was an error setting user {0} to active in Seafile".format(ldapUser.mail))
|
||||||
else:
|
else:
|
||||||
logger.error("Failed to add LDAP user {0} to the SQL Table".format(ldapUser.mail))
|
logger.error("Failed to add LDAP user {0} to the SQL Table".format(ldapUser.mail))
|
||||||
cnx.close()
|
cnx.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user