Exemplo n.º 1
0
 def clean_email(self):
     email = self.data.get("email")
     if email.endswith("@cnstrong.cn"):
         user = email.split("@")[0]
         client = ClientMeta(host=IPA_AUTH_SERVER, verify_ssl=False)
         client.login(IPA_AUTH_USER, IPA_AUTH_PWD)
         account = client.user_find(user)
         if account:
             print("account is:", account)
         else:
             print("No user: "******"no right mail:", email)
         raise forms.ValidationError('非公司邮箱')
     return email
Exemplo n.º 2
0

# Function to convert list to string
def listToString(s):
    # initialize an empty string
    str1 = ""
    # traverse in the string
    for ele in s:
        str1 += ele + ","
    # return string
    return str1


# Get all IDM users
# use the freeipa module user_find method and store in userlist list
userlist = client.user_find()
#print userlist.items()
# get sub category result
userresult = userlist.get("result")
# declare empty list
listofusers = []
# pad the empty list with a header line
listofusers.append(['USER NAME', 'FULL NAME', 'GROUPS'])
# loop through each line in list
for row in userresult:
    # declare empty list where we inserts 3 elements of all user elements
    user = []
    user.append(row.get('uid')[0])
    user.append(row.get('cn')[0])
    user.append(listToString(row.get('memberof_group')))
    # add user list to bigger list of all users