def check_ldap_access_groups(self, server, username): #Avoid circular import from is_admin from useradmin.views import get_find_groups_filter allowed_group = False if LDAP.LOGIN_GROUPS.get() and LDAP.LOGIN_GROUPS.get() != ['']: login_groups = LDAP.LOGIN_GROUPS.get() connection = ldap_access.get_connection_from_server(server) try: user_info = connection.find_users(username, find_by_dn=False) except Exception as e: LOG.warn("Failed to find LDAP user: %s" % e) if not user_info: LOG.warn( "Could not get LDAP details for users with pattern %s" % username) return False ldap_info = user_info[0] group_ldap_info = connection.find_groups( "*", group_filter=get_find_groups_filter(ldap_info, server)) for group in group_ldap_info: if group['name'] in login_groups: return True else: #Login groups not set default to True allowed_group = True return allowed_group
def check_ldap_access_groups(self, server, username): #Avoid circular import from is_admin from useradmin.views import get_find_groups_filter allowed_group = False if desktop.conf.LDAP.LOGIN_GROUPS.get() and desktop.conf.LDAP.LOGIN_GROUPS.get() != ['']: login_groups = desktop.conf.LDAP.LOGIN_GROUPS.get() connection = ldap_access.get_connection_from_server(server) try: user_info = connection.find_users(username, find_by_dn=False) except Exception, e: LOG.warn("Failed to find LDAP user: %s" % e) if not user_info: LOG.warn("Could not get LDAP details for users with pattern %s" % username) return False ldap_info = user_info[0] group_ldap_info = connection.find_groups("*", group_filter=get_find_groups_filter(ldap_info, server)) for group in group_ldap_info: if group['name'] in login_groups: return True
def check_ldap_access_groups(self, server, username): allowed_group = False if desktop.conf.LDAP.LOGIN_GROUPS.get( ) and desktop.conf.LDAP.LOGIN_GROUPS.get() != ['']: login_groups = desktop.conf.LDAP.LOGIN_GROUPS.get() connection = ldap_access.get_connection_from_server(server) try: user_info = connection.find_users(username, find_by_dn=False) except LdapSearchException, e: LOG.warn("Failed to find LDAP user: %s" % e) if not user_info: LOG.warn( "Could not get LDAP details for users with pattern %s" % username_pattern) return None ldap_info = user_info[0] group_ldap_info = connection.find_groups( "*", group_filter=get_find_groups_filter(ldap_info)) for group in group_ldap_info: if group['name'] in login_groups: allowed_group = True