def main(reactor, args): endpoint_str = args.endpoint e = clientFromString(reactor, endpoint_str) d = connectProtocol(e, LDAPClient()) d.addCallback(onConnect, args) d.addErrback(onError) return d
def main(reactor): endpoint_str = "tcp:host=127.0.0.1:port=13891" e = clientFromString(reactor, endpoint_str) d = connectProtocol(e, LDAPClient()) d.addCallback(onConnect) d.addErrback(onError) return d
def main(reactor): log.startLogging(sys.stdout) endpoint_str = "tcp:host=localhost:port=8080" e = clientFromString(reactor, endpoint_str) d = connectProtocol(e, LDAPClient()) d.addCallback(onConnect) d.addErrback(onError, reactor) return d
def _get_avatar(self, avatarId, mind): endpointstr = self._endpointstr basedn = self._basedn binddn = self._binddn bindpw = self._bindpw query = self._query_template % { 'username': escape_filter_chars(avatarId) } if self._service_based_attribs: if mind: service = mind['service'] else: service = "" if service == "" or service is None or self.service_manager is None: attributes = self._attribs else: service_entry = yield defer.maybeDeferred( self.service_manager.getMatchingService, service) if service_entry and 'attributes' in service_entry: attributes = service_entry['attributes'] else: attributes = self._attribs else: attributes = self._attribs e = clientFromString(reactor, self._endpointstr) client = yield connectProtocol(e, LDAPClient()) startTls = self._startTls startTlsHostName = self._startTlsHostName startTlsAuthority = self._startTlsAuthority if startTls: startTlsArgs = [] if startTlsHostName is not None: if startTlsAuthority is not None: ctx = optionsForClientTLS(unicode(startTlsHostName), startTlsAuthority) else: ctx = optionsForClientTLS(unicode(startTlsHostName), platformTrust()) startTlsArgs.append(ctx) client = yield client.startTLS(*startTlsArgs) yield client.bind(binddn, bindpw) o = ldapsyntax.LDAPEntry(client, basedn) results = yield o.search(filterText=query, attributes=attributes.keys()) yield client.unbind() if len(results) != 1: raise Exception("No unique account found for '%s'." % avatarId) entry = results[0] _attribs = attributes attribs = [] for key, alias in _attribs.iteritems(): if key in entry: valuelist = entry[key] for value in valuelist: attribs.append((alias, value)) user = User(avatarId, attribs) defer.returnValue(user)
def main(reactor): log.startLogging(sys.stdout) entry = { "dn": "gn=Jane+sn=Doe,ou=people,dc=example,dc=fr", "c": "US", "gn": "Jane", "l": "Philadelphia", "objectClass": "addressbookPerson", "postalAddress": "230", "postalCode": "314159", "sn": "Doe", "st": "PA", "street": "Mobius Strip", "userPassword": "******", } endpoint_str = "tcp:host=localhost:port=8080" e = clientFromString(reactor, endpoint_str) d = connectProtocol(e, LDAPClient()) d.addCallback(onConnect, entry) d.addErrback(onError, reactor) return d
def _make_connect(self, credentials): basedn = self._basedn e = clientFromString(reactor, self._endpointstr) client = yield connectProtocol(e, LDAPClient()) startTls = self._startTls startTlsHostName = self._startTlsHostName startTlsAuthority = self._startTlsAuthority if startTls: startTlsArgs = [] if startTlsHostName is not None: if startTlsAuthority is not None: ctx = optionsForClientTLS(unicode(startTlsHostName), startTlsAuthority) else: ctx = optionsForClientTLS(unicode(startTlsHostName), platformTrust()) startTlsArgs.append(ctx) client = yield client.startTLS(*startTlsArgs) dn = yield self._get_dn(client, credentials.username) yield client.bind(dn, credentials.password) yield client.unbind() defer.returnValue(credentials.username)
def create_server_and_client(self, *responses, **kwds): client = LDAPClient() server = self.create_server(*responses, **kwds) self.pumps.add(returnConnected(server, client)) return server, client
def buildProtocol(self, address): return LDAPClient()