summaryrefslogtreecommitdiff
path: root/ldap3/operation/bind.py
diff options
context:
space:
mode:
Diffstat (limited to 'ldap3/operation/bind.py')
-rw-r--r--ldap3/operation/bind.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/ldap3/operation/bind.py b/ldap3/operation/bind.py
index a74b04a..43ad1fb 100644
--- a/ldap3/operation/bind.py
+++ b/ldap3/operation/bind.py
@@ -5,7 +5,7 @@
#
# Author: Giovanni Cannata
#
-# Copyright 2013 - 2018 Giovanni Cannata
+# Copyright 2013 - 2020 Giovanni Cannata
#
# This file is part of ldap3.
#
@@ -25,7 +25,7 @@
from .. import SIMPLE, ANONYMOUS, SASL, STRING_TYPES
from ..core.results import RESULT_CODES
-from ..core.exceptions import LDAPPasswordIsMandatoryError, LDAPUnknownAuthenticationMethodError, LDAPUserNameNotAllowedError
+from ..core.exceptions import LDAPUserNameIsMandatoryError, LDAPPasswordIsMandatoryError, LDAPUnknownAuthenticationMethodError, LDAPUserNameNotAllowedError
from ..protocol.sasl.sasl import validate_simple_password
from ..protocol.rfc4511 import Version, AuthenticationChoice, Simple, BindRequest, ResultCode, SaslCredentials, BindResponse, \
LDAPDN, LDAPString, Referral, ServerSaslCreds, SicilyPackageDiscovery, SicilyNegotiate, SicilyResponse
@@ -52,7 +52,7 @@ def bind_operation(version,
request['name'] = to_unicode(name) if auto_encode else name
if authentication == SIMPLE:
if not name:
- raise LDAPPasswordIsMandatoryError('user name is mandatory in simple bind')
+ raise LDAPUserNameIsMandatoryError('user name is mandatory in simple bind')
if password:
request['authentication'] = AuthenticationChoice().setComponentByName('simple', Simple(validate_simple_password(password)))
else:
@@ -122,7 +122,7 @@ def bind_response_to_dict(response):
'description': ResultCode().getNamedValues().getName(response['resultCode']),
'dn': str(response['matchedDN']),
'message': str(response['diagnosticMessage']),
- 'referrals': referrals_to_list(response['referral']),
+ 'referrals': referrals_to_list(response['referral']) if response['referral'] is not None and response['referral'].hasValue() else [],
'saslCreds': bytes(response['serverSaslCreds']) if response['serverSaslCreds'] is not None and response['serverSaslCreds'].hasValue() else None}