def connect_service_account(self):
"""
Make a new connection to the LDAP backend server using the credentials of the service account
:return: A Deferred that fires a `LDAPClient` instance
"""
client = yield connectToLDAPEndpoint(reactor, self.proxied_endpoint_string, LDAPClient)
if self.use_tls:
client = yield client.startTLS()
try:
yield client.bind(self.service_account_dn, self.service_account_password)
except ldaperrors.LDAPException, e:
# Call unbind() here if an exception occurs: Otherwise, Twisted will keep the file open
# and slowly run out of open files.
yield client.unbind()
raise e
defer.returnValue(client)
评论列表
文章目录