def update_user_groups(username, password, groups): try: api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY) api.update_user(username, password, "", "", groups) except exception.HTTPException as e: print e
def delete_user(username): try: api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY) api.delete_user(username) return True except exception.UserNotFoundException: return False
def update_user_pass(username): try: password = OpenfireManager.__generate_random_pass() api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY) api.update_user(username, password) return password except exception.UserNotFoundException: return ""
def add_user(username): try: sanatized_username = OpenfireManager.__santatize_username(username) password = OpenfireManager.__generate_random_pass() api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY) api.add_user(sanatized_username, password) except exception.UserAlreadyExistsException: # User exist return "", "" return sanatized_username, password
def add_xmpp_jid(jid): #Get xmpp server url from properties.py file xmppServer = properties.xmppServerUrl #Login to the xmpp server api = UserService(xmppServer, "skAljQTm43929-49sdakl") try: #Add users from the input csv file userAddReturnValue = api.add_user(jid, "skAljQTm43929-49sdakl") print "User " + jid + " added successfully!!" #print userAddReturnValue except UserAlreadyExistsException: print "User " + jid + " already exists!" except UserNotFoundException: print "User " + jid + " not found!!" except InvalidResponseException: print "Invalid request" except RequestNotAuthorisedException: print "Request is not authorized"
def delete_user_groups(username, groups): api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY) api.delete_group(username, groups)
def unlock_user(username): api = UserService(settings.OPENFIRE_ADDRESS, settings.OPENFIRE_SECRET_KEY) api.unlock_user(username)