diff --git a/seahub/base/accounts.py b/seahub/base/accounts.py index 5c3f4f5f2fa..4a80e0a3bc9 100644 --- a/seahub/base/accounts.py +++ b/seahub/base/accounts.py @@ -63,6 +63,8 @@ UNUSABLE_PASSWORD = '!' # This will never be a valid hash +SSO_LDAP_USE_SAME_UID = getattr(settings, 'SSO_LDAP_USE_SAME_UID', False) + def default_ldap_role_mapping(role): return role @@ -964,6 +966,8 @@ def authenticate(self, ldap_user=None, password=None): # search user from ldap server try: auth_user = SocialAuthUser.objects.filter(username=ldap_user, provider=LDAP_PROVIDER).first() + if not auth_user and SSO_LDAP_USE_SAME_UID: + auth_user = SocialAuthUser.objects.filter(username=ldap_user).first() if auth_user: login_attr = auth_user.uid else: @@ -977,6 +981,8 @@ def authenticate(self, ldap_user=None, password=None): except Exception as e: if ENABLE_MULTI_LDAP: auth_user = SocialAuthUser.objects.filter(username=ldap_user, provider=MULTI_LDAP_1_PROVIDER).first() + if not auth_user and SSO_LDAP_USE_SAME_UID: + auth_user = SocialAuthUser.objects.filter(username=ldap_user).first() if auth_user: login_attr = auth_user.uid else: