我正在尝试使用ldap配置我的应用程序 . 我正在使用ldap3 . 我收到此错误:

文件C中的非ASCII字符'\ xe2':\ Documents \ dm050767 \ Documents \ UserProfile \ auth \ auth_backend.py以下是文件:

settings.py

AUTHENTICATION_BACKENDS = [

    'auth.auth_backend.UserAuthentication',
]

views.py

def login_user(request):
    username = request.POST['username']
    password = request.POST['password']
    print(username,password)
    user = authenticate(request, username=username, 
    password=password)
    print(user)
    if user is not None:
        print('User not none')
        login(request, user)
        print('Login successful')
        return redirect(request.POST['next'] or '/')
    else:
        print('Login failed')
        return redirect('/login?error=auth')


def login_view(request):
    if request.method == "POST":
        return login_user(request)
    else:
        return render(request, 'Profile/login.html')

auth/auth_backend.py

class UserAuthentication:

    def authenticate(self, request, username=None, 
    password=None, domain="domain"):
        # TODO add error handling when uid and or pwd is not 
    passed
        # Check the username/password and return a user. If 
not valid, it should return None.
        user = domain + username
        server = Server('server', get_info=ALL)
        conn = Connection(server, user=user, 
password=password, authentication=NTLM)
        valid_user = conn.bind()
        if valid_user:
            try:
                user = User.objects.get(username=username)
                if settings.DEBUG:
                    print("YouRockAuth.authenticate: found 
 user %s" % user.username)
            except User.DoesNotExist:
               pass
        else:
            user = None
        return user

    def get_user(self, user_id):

        try:
            user = User.objects.get(pk=user_id)
            return user
        except User.DoesNotExist:
            return None