def is_valid_user (mail):
    mail = mail.strip()
    ## If the regex search below fails, comment out the conditional and the return. Then Uncomment the following line to atleat sanitize the input
    mail = mail.replace("(",'').replace(")",'').replace("'",'').replace('"','').replace(';','').replace("\"",'')
    #if not re.search("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", mail):
    #     return 'Invalid Email Address'
    account_status = get_ldap_attribute (mail, 'hgAccountEnabled', 'ldap://ldap.db.scl3.mozilla.com')
    if account_status == 'TRUE':
        return 1
    elif account_status == 'FALSE':
        return 2
    else:
        return 0
Ejemplo n.º 2
0
def is_valid_user(mail):
    url = get_ldap_settings()['url']

    mail = mail.strip()
    replacements = {
        '(': '',
        ')': '',
        "'": '',
        '"': '',
        ';': '',
    }
    for search, replace in replacements.items():
        mail = mail.replace(search, replace)
    account_status = get_ldap_attribute(mail, 'hgAccountEnabled', url)
    if account_status == 'TRUE':
        return 1
    elif account_status == 'FALSE':
        return 2
    else:
        return 0
def is_valid_user(mail):
    url = get_ldap_settings()['url']

    mail = mail.strip()
    replacements = {
        '(': '',
        ')': '',
        "'": '',
        '"': '',
        ';': '',
    }
    for search, replace in replacements.items():
        mail = mail.replace(search, replace)
    account_status = get_ldap_attribute(mail, 'hgAccountEnabled', url)
    if account_status == 'TRUE':
        return 1
    elif account_status == 'FALSE':
        return 2
    else:
        return 0