Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def process_entry(client, args, search_filter, page_size=100, cookie=''):
basedn = args.base_dn
control_value = pureber.BERSequence([
pureber.BERInteger(page_size),
pureber.BEROctetString(cookie),
])
controls = [('1.2.840.113556.1.4.319', None, control_value)]
o = LDAPEntry(client, basedn)
results, resp_controls = yield o.search(
filterText=search_filter,
attributes=['dn'],
controls=controls,
return_controls=True)
cookie = get_paged_search_cookie(resp_controls)
defer.returnValue((results, cookie))
def _doSearch(proto):
searchFilter = ldapfilter.parseFilter('(gn=j*)')
baseEntry = ldapsyntax.LDAPEntry(client=proto,
dn=self.config.getBaseDN())
d=baseEntry.search(filterObject=searchFilter)
return d
def data_servicePasswords(self, ctx, data):
user = ctx.locate(inevow.ISession).getLoggedInRoot().loggedIn
config = interfaces.ILDAPConfig(ctx)
e=ldapsyntax.LDAPEntry(client=user.client, dn=config.getBaseDN())
d = e.search(filterObject=pureldap.LDAPFilter_and([
pureldap.LDAPFilter_equalityMatch(attributeDesc=pureldap.LDAPAttributeDescription('objectClass'),
assertionValue=pureldap.LDAPAssertionValue('serviceSecurityObject')),
pureldap.LDAPFilter_equalityMatch(attributeDesc=pureldap.LDAPAttributeDescription('owner'),
assertionValue=pureldap.LDAPAssertionValue(str(self.dn))),
pureldap.LDAPFilter_present('cn'),
]),
attributes=['cn'])
return d
def onConnect(client):
# The following arguments may be also specified as unicode strings
# but it is recommended to use byte strings for ldaptor objects
basedn = b'dc=example,dc=org'
binddn = b'cn=bob,ou=people,dc=example,dc=org'
bindpw = b'secret'
query = b'(cn=bob)'
try:
yield client.bind(binddn, bindpw)
except Exception as ex:
print(ex)
raise
o = LDAPEntry(client, basedn)
results = yield o.search(filterText=query)
for entry in results:
print(entry.getLDIF())
def _nonUserEditableAttributeType_getFreeNumber(self, attributeType, context):
cfg = context.locate(interfaces.ILDAPConfig)
entry = context.locate(inevow.ISession).getLoggedInRoot().loggedIn
client = entry.client
o=ldapsyntax.LDAPEntry(client=client,
dn=cfg.getBaseDN())
d=numberalloc.getFreeNumber(ldapObject=o,
numberType=attributeType,
min=1000)
d.addCallback(lambda x, a=attributeType: (a, [str(x)]))
return d
def _search(proto, base, connection, numOfSearches):
l=[]
baseEntry = ldapsyntax.LDAPEntry(client=proto,
dn=base)
for search in xrange(0, numOfSearches):
d=baseEntry.search(callback=lambda x:
_handle_entry(x, connection, search))
d.addErrback(error)
l.append(d)
dl=defer.DeferredList(l)
return dl