def _bind_for_search(anonymous=False, opts=None):
 connargs = {}
 params = {'mandatory': ['uri', 'server', 'port', 'tls', 'no_verify', 'anonymous', 'accountattributename', 'activedirectory'], 'additional': ['binddn', 'bindpw', 'filter', 'groupclass', 'auth_by_group_membership_only']}
 paramvalues = {}
 for param in params['mandatory']:
  paramvalues[param] = _config(param, opts=opts)
 for param in params['additional']:
  paramvalues[param] = _config(param, mandatory=False, opts=opts)
 paramvalues['anonymous'] = anonymous
 if paramvalues['binddn']:
  connargs['binddn'] = paramvalues['binddn']
  if paramvalues['bindpw']:
   params['mandatory'].append('bindpw')
 for name in params['mandatory']:
  connargs[name] = paramvalues[name]
 if (not paramvalues['anonymous']):
  if (paramvalues['binddn'] and paramvalues['bindpw']):
   return _LDAPConnection(**connargs).ldap

def _bind_for_search ( anonymous = False , opts = None ) : connargs = { } params = { 'mandatory' : [ 'uri' , 'server' , 'port' , 'tls' , 'no_verify' , 'anonymous' , 'accountattributename' , 'activedirectory' ] , 'additional' : [ 'binddn' , 'bindpw' , 'filter' , 'groupclass' , 'auth_by_group_membership_only' ] } paramvalues = { } for param in params [ 'mandatory' ] : paramvalues [ param ] = _config ( param , opts = opts ) for param in params [ 'additional' ] : paramvalues [ param ] = _config ( param , mandatory = False , opts = opts ) paramvalues [ 'anonymous' ] = anonymous if paramvalues [ 'binddn' ] : connargs [ 'binddn' ] = paramvalues [ 'binddn' ] if paramvalues [ 'bindpw' ] : params [ 'mandatory' ] . append ( 'bindpw' ) for name in params [ 'mandatory' ] : connargs [ name ] = paramvalues [ name ] if ( not paramvalues [ 'anonymous' ] ) : if ( paramvalues [ 'binddn' ] and paramvalues [ 'bindpw' ] ) : return _LDAPConnection ( ** connargs ) . ldap
bind with binddn and bindpw only for searching ldap .