def GET(self): form = web.input() return web.render('sql/admin/create.html', languagemaps=iredutils.get_language_maps(), default_language=settings.default_language, min_passwd_length=settings.min_passwd_length, max_passwd_length=settings.max_passwd_length, password_policies=iredutils.get_password_policies(), msg=form.get('msg'))
def GET(self, domain): domain = str(domain).lower() form = web.input() # Get all managed domains. _wrap = SQLWrap() conn = _wrap.conn if session.get('is_global_admin'): qr = sql_lib_domain.get_all_domains(conn=conn, name_only=True) else: qr = sql_lib_admin.get_managed_domains( conn=conn, admin=session.get('username'), domain_name_only=True) if qr[0] is True: all_domains = qr[1] else: raise web.seeother('/domains?msg=' + web.urlquote(qr[1])) # Get domain profile. qr_profile = sql_lib_domain.simple_profile(domain=domain, conn=conn) if qr_profile[0] is True: domain_profile = qr_profile[1] domain_settings = sqlutils.account_settings_string_to_dict( domain_profile['settings']) else: raise web.seeother('/domains?msg=%s' % web.urlquote(qr_profile[1])) # Cet total number and allocated quota size of existing users under domain. num_users_under_domain = sql_lib_general.num_users_under_domain( domain=domain, conn=conn) min_passwd_length = domain_settings.get('min_passwd_length', settings.min_passwd_length) max_passwd_length = domain_settings.get('max_passwd_length', settings.max_passwd_length) return web.render( 'sql/user/create.html', cur_domain=domain, allDomains=all_domains, profile=domain_profile, domain_settings=domain_settings, min_passwd_length=min_passwd_length, max_passwd_length=max_passwd_length, store_password_in_plain_text=settings.STORE_PASSWORD_IN_PLAIN_TEXT, num_existing_users=num_users_under_domain, languagemaps=iredutils.get_language_maps(), password_policies=iredutils.get_password_policies(), msg=form.get('msg'), )
def GET(self, domain): domain = str(domain).lower() form = web.input() _wrap = LDAPWrap() conn = _wrap.conn _attrs = ['domainName', 'accountSetting', 'domainCurrentQuotaSize'] result = ldap_lib_domain.list_accounts(attributes=_attrs, conn=conn) if result[0] is True: allDomains = result[1] # Get accountSetting of current domain. allAccountSettings = ldaputils.get_account_settings_from_qr( allDomains) domainAccountSetting = allAccountSettings.get(domain, {}) defaultUserQuota = ldap_lib_domain.get_default_user_quota( domain=domain, domain_account_setting=domainAccountSetting) else: raise web.seeother('/domains?msg=' + web.urlquote(result[1])) # Get number of account limit. numberOfCurrentAccounts = ldap_lib_general.num_users_under_domain( domain=domain, conn=conn) (min_passwd_length, max_passwd_length) = ldap_lib_general.get_domain_password_lengths( domain=domain, account_settings=domainAccountSetting, fallback_to_global_settings=True, ) return web.render( 'ldap/user/create.html', cur_domain=domain, allDomains=allDomains, defaultUserQuota=defaultUserQuota, domainAccountSetting=domainAccountSetting, min_passwd_length=min_passwd_length, max_passwd_length=max_passwd_length, store_password_in_plain_text=settings.STORE_PASSWORD_IN_PLAIN_TEXT, password_policies=iredutils.get_password_policies(), numberOfCurrentAccounts=numberOfCurrentAccounts, languagemaps=iredutils.get_language_maps(), msg=form.get('msg'))
def GET(self): form = web.input() db_settings = iredutils.get_settings_from_db() min_passwd_length = db_settings['min_passwd_length'] max_passwd_length = db_settings['max_passwd_length'] password_policies = iredutils.get_password_policies( db_settings=db_settings) return web.render('ldap/admin/create.html', languagemaps=iredutils.get_language_maps(), default_language=settings.default_language, min_passwd_length=min_passwd_length, max_passwd_length=max_passwd_length, password_policies=password_policies, msg=form.get('msg'))
def GET(self): form = web.input() _wrap = SQLWrap() conn = _wrap.conn all_domains = sql_lib_domain.get_all_domains(conn=conn, name_only=True) if all_domains[0]: all_domains = all_domains[1] else: all_domains = [] return web.render('sql/admin/create.html', languagemaps=iredutils.get_language_maps(), domains=all_domains, default_language=settings.default_language, min_passwd_length=settings.min_passwd_length, max_passwd_length=settings.max_passwd_length, password_policies=iredutils.get_password_policies(), msg=form.get('msg'))
def GET(self, profile_type, mail): mail = str(mail).lower() form = web.input() if not (session.get('is_global_admin') or session.get('username') == mail): # Don't allow to view/update others' profile. raise web.seeother( '/profile/admin/general/%s?msg=PERMISSION_DENIED' % session.get('username')) _wrap = SQLWrap() conn = _wrap.conn is_global_admin = sql_lib_general.is_global_admin(admin=mail, conn=conn) result = sql_lib_admin.get_profile(mail=mail, conn=conn) if result[0] is True: profile = result[1] qr = sql_lib_general.get_admin_settings(admin=mail, conn=conn) if qr[0]: admin_settings = qr[1] else: return qr # Get all domains. all_domains = [] qr_all_domains = sql_lib_domain.get_all_domains(conn=conn) if qr_all_domains[0] is True: all_domains = qr_all_domains[1] # Get managed domains. managed_domains = [] qr = sql_lib_admin.get_managed_domains(conn=conn, admin=mail, domain_name_only=True, listed_only=True) if qr[0] is True: managed_domains += qr[1] return web.render( 'sql/admin/profile.html', mail=mail, profile_type=profile_type, is_global_admin=is_global_admin, profile=profile, admin_settings=admin_settings, languagemaps=iredutils.get_language_maps(), allDomains=all_domains, managedDomains=managed_domains, min_passwd_length=settings.min_passwd_length, max_passwd_length=settings.max_passwd_length, store_password_in_plain_text=settings. STORE_PASSWORD_IN_PLAIN_TEXT, password_policies=iredutils.get_password_policies(), msg=form.get('msg'), ) else: # Return to user profile page if admin is a mail user. qr = sql_lib_user.simple_profile(conn=conn, mail=mail, columns=['username']) if qr[0]: raise web.seeother('/profile/user/general/' + mail) else: raise web.seeother('/admins?msg=' + web.urlquote(result[1]))
def GET(self, mail): mail = str(mail).lower() domain = mail.split('@', 1)[-1] _wrap = SQLWrap() conn = _wrap.conn form = web.input() msg = form.get('msg', '') used_quota = {} qr = sql_lib_user.profile(mail=mail, conn=conn) if qr[0]: user_profile = qr[1] else: raise web.seeother('/api?msg={}'.format(web.urlquote(qr[1]))) del qr # Get per-user settings user_settings = {} qr = sql_lib_general.get_user_settings( conn=conn, mail=mail, existing_settings=user_profile['settings']) if qr[0]: user_settings = qr[1] del qr # Get used quota. if settings.SHOW_USED_QUOTA: used_quota = sql_lib_general.get_account_used_quota( accounts=[mail], conn=conn) # Get per-domain disabled user profiles. qr = sql_lib_domain.simple_profile(conn=conn, domain=domain, columns=['settings']) if qr[0]: domain_profile = qr[1] domain_settings = sqlutils.account_settings_string_to_dict( domain_profile['settings']) min_passwd_length = domain_settings.get('min_passwd_length', settings.min_passwd_length) max_passwd_length = domain_settings.get('max_passwd_length', settings.max_passwd_length) return web.render('api/msg/msg.html', content_type="application/json", msg={ "cur_domain": domain, "mail": mail, "profile": user_profile, "timezones": TIMEZONES, "min_passwd_length": min_passwd_length, "max_passwd_length": max_passwd_length, "store_password_in_plain_text": settings.STORE_PASSWORD_IN_PLAIN_TEXT, "password_policies": iredutils.get_password_policies(), "user_settings": user_settings, "used_quota": used_quota, "languagemaps": iredutils.get_language_maps(), "msg": msg, })
def GET(self, profile_type, mail): mail = str(mail).lower() domain = mail.split('@', 1)[-1] if not session.get('is_global_admin') and not session.get('is_admin'): mail = session.get("username") if session.get('is_admin'): #check if admin asking for details of correct domain admins_of_domain = sql_lib_domain.get_domain_admin_addresses( domain=domain)[1] if session.get( 'username' ) not in admins_of_domain and not session.get('is_global_admin'): raise web.seeother('/domains?msg=PERMISSION_DENIED') _wrap = SQLWrap() conn = _wrap.conn form = web.input() msg = form.get('msg', '') # profile_type == 'general' used_quota = {} qr = sql_lib_user.profile(mail=mail, conn=conn) if qr[0]: user_profile = qr[1] else: if not session.get('is_global_admin') and not session.get( 'is_admin'): raise web.seeother('/users/{}?msg={}'.format( domain, web.urlquote(qr[1]))) else: raise web.seeother("/dashboard?msg=SOMETHING_WENT_WRONG") del qr # Get per-user settings user_settings = {} qr = sql_lib_general.get_user_settings( conn=conn, mail=mail, existing_settings=user_profile['settings']) if qr[0]: user_settings = qr[1] del qr # Get used quota. if settings.SHOW_USED_QUOTA: used_quota = sql_lib_general.get_account_used_quota( accounts=[mail], conn=conn) # Get per-domain disabled user profiles. qr = sql_lib_general.get_domain_settings(conn=conn, domain=domain) if qr[0]: domain_settings = qr[1] min_passwd_length = domain_settings.get('min_passwd_length', settings.min_passwd_length) max_passwd_length = domain_settings.get('max_passwd_length', settings.max_passwd_length) return web.render( 'sql/user/profile.html', cur_domain=domain, mail=mail, profile_type=profile_type, profile=user_profile, timezones=TIMEZONES, min_passwd_length=min_passwd_length, max_passwd_length=max_passwd_length, store_password_in_plain_text=settings.STORE_PASSWORD_IN_PLAIN_TEXT, password_policies=iredutils.get_password_policies(), user_settings=user_settings, used_quota=used_quota, languagemaps=iredutils.get_language_maps(), msg=msg, )
def GET(self, profile_type, mail): mail = str(mail).lower() domain = mail.split('@', 1)[-1] _wrap = SQLWrap() conn = _wrap.conn form = web.input() msg = form.get('msg', '') # profile_type == 'general' used_quota = {} qr = sql_lib_user.profile(mail=mail, conn=conn) if qr[0]: user_profile = qr[1] else: raise web.seeother('/users/{}?msg={}'.format( domain, web.urlquote(qr[1]))) del qr # Get per-user settings user_settings = {} qr = sql_lib_general.get_user_settings( conn=conn, mail=mail, existing_settings=user_profile['settings']) if qr[0]: user_settings = qr[1] del qr # Get used quota. if settings.SHOW_USED_QUOTA: used_quota = sql_lib_general.get_account_used_quota( accounts=[mail], conn=conn) # Get per-domain disabled user profiles. qr = sql_lib_domain.simple_profile(conn=conn, domain=domain, columns=['settings']) if qr[0]: domain_profile = qr[1] domain_settings = sqlutils.account_settings_string_to_dict( domain_profile['settings']) min_passwd_length = domain_settings.get('min_passwd_length', settings.min_passwd_length) max_passwd_length = domain_settings.get('max_passwd_length', settings.max_passwd_length) return web.render( 'sql/user/profile.html', cur_domain=domain, mail=mail, profile_type=profile_type, profile=user_profile, timezones=TIMEZONES, min_passwd_length=min_passwd_length, max_passwd_length=max_passwd_length, store_password_in_plain_text=settings.STORE_PASSWORD_IN_PLAIN_TEXT, password_policies=iredutils.get_password_policies(), user_settings=user_settings, used_quota=used_quota, languagemaps=iredutils.get_language_maps(), msg=msg, )
def GET(self, profile_type, mail): mail = str(mail).lower() cur_domain = mail.split('@', 1)[-1] form = web.input(enabledService=[], telephoneNumber=[], domainName=[]) msg = form.get('msg') profile_type = web.safestr(profile_type) _wrap = LDAPWrap() conn = _wrap.conn qr = ldap_lib_user.get_profile(mail=mail, conn=conn) if not qr[0]: raise web.seeother('/users/{}?msg={}'.format( cur_domain, web.urlquote(qr[1]))) user_profile = qr[1]['ldif'] user_account_setting = ldaputils.account_setting_list_to_dict( user_profile.get('accountSetting', [])) # profile_type == 'general' accountUsedQuota = {} # Per-domain account settings domainAccountSetting = {} # Get accountSetting of current domain. qr = ldap_lib_general.get_domain_account_setting(domain=cur_domain, conn=conn) if qr[0] is True: domainAccountSetting = qr[1] if profile_type == 'general': # Get account used quota. if settings.SHOW_USED_QUOTA: accountUsedQuota = ldap_lib_general.get_account_used_quota( [mail]) (min_passwd_length, max_passwd_length) = ldap_lib_general.get_domain_password_lengths( domain=cur_domain, account_settings=domainAccountSetting, fallback_to_global_settings=False) password_policies = iredutils.get_password_policies() if min_passwd_length > 0: password_policies['min_passwd_length'] = min_passwd_length if max_passwd_length > 0: password_policies['max_passwd_length'] = max_passwd_length return web.render( 'ldap/user/profile.html', profile_type=profile_type, mail=mail, user_profile=user_profile, user_account_setting=user_account_setting, defaultStorageBaseDirectory=settings.storage_base_directory, timezones=TIMEZONES, min_passwd_length=min_passwd_length, max_passwd_length=max_passwd_length, store_password_in_plain_text=settings.STORE_PASSWORD_IN_PLAIN_TEXT, password_policies=iredutils.get_password_policies(), accountUsedQuota=accountUsedQuota, domainAccountSetting=domainAccountSetting, languagemaps=iredutils.get_language_maps(), msg=msg, )
def GET(self, profile_type, mail): mail = web.safestr(mail).lower() profile_type = web.safestr(profile_type) if not (session.get('is_global_admin') or session.get('username') == mail): # Don't allow to view/update other admins' profile. raise web.seeother( '/profile/admin/general/%s?msg=PERMISSION_DENIED' % session.get('username')) _wrap = LDAPWrap() conn = _wrap.conn # Get admin profile. qr = ldap_lib_admin.get_profile(mail=mail, conn=conn) if qr[0]: admin_profile = qr[1]['ldif'] account_settings = ldaputils.get_account_setting_from_profile( admin_profile) _qr = ldap_lib_general.get_admin_account_setting( mail=mail, profile=admin_profile, conn=conn) if _qr[0]: account_settings = _qr[1] else: raise web.seeother('/admins?msg=' + qr[1]) form = web.input() if profile_type in ['general', 'password']: # Get all domains. qr_all_domains = ldap_lib_domain.list_accounts( attributes=['domainName', 'cn'], conn=conn) if qr_all_domains[0] is True: all_domains = qr_all_domains[1] else: return qr_all_domains # Get domains under control. qr_managed_domains = ldap_lib_admin.get_managed_domains( admin=mail, attributes=['domainName'], domain_name_only=True, conn=conn) if qr_managed_domains[0] is True: managed_domains = qr_managed_domains[1] else: return qr_managed_domains return web.render( 'ldap/admin/profile.html', mail=mail, profile_type=profile_type, admin_profile=admin_profile, account_settings=account_settings, languagemaps=iredutils.get_language_maps(), allDomains=all_domains, managedDomains=managed_domains, min_passwd_length=settings.min_passwd_length, max_passwd_length=settings.max_passwd_length, store_password_in_plain_text=settings. STORE_PASSWORD_IN_PLAIN_TEXT, password_policies=iredutils.get_password_policies(), timezones=TIMEZONES, msg=form.get('msg', None), )