1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-03-22 10:34:49 +00:00

Check for ldap3 existence

This commit is contained in:
Kendar 2021-05-28 12:55:47 +02:00
parent 881852af05
commit b761faccec

View file

@ -1,12 +1,13 @@
from django.contrib.auth.backends import ModelBackend from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.models import User from django.contrib.auth.models import User
from ldap3 import Server, Connection, ALL
from django.conf import settings from django.conf import settings
from accounts.models import UserAttributes, UserInstance, UserSSHKey from accounts.models import UserAttributes, UserInstance, UserSSHKey
from django.contrib.auth.models import Permission from django.contrib.auth.models import Permission
from logs.models import Logs from logs.models import Logs
import uuid import uuid
try:
from ldap3 import Server, Connection, ALL
#/srv/webvirtcloud/ldap/ldapbackend.py #/srv/webvirtcloud/ldap/ldapbackend.py
class LdapAuthenticationBackend(ModelBackend): class LdapAuthenticationBackend(ModelBackend):
@ -107,3 +108,9 @@ class LdapAuthenticationBackend(ModelBackend):
except User.DoesNotExist: except User.DoesNotExist:
print("get_user-user not found") print("get_user-user not found")
return None return None
except:
class LdapAuthenticationBackend(ModelBackend):
def authenticate(self, request, username=None, password=None, **kwargs):
return None
def get_user(self, user_id):
return None