def _do_search(conf):
 connargs = {}
 for name in ['server', 'port', 'tls', 'binddn', 'bindpw', 'anonymous']:
  connargs[name] = _config(name, conf)
 if (connargs['binddn'] and connargs['bindpw']):
  connargs['anonymous'] = False
 try:
  _filter = conf['filter']
 except KeyError:
  raise SaltInvocationError('missing filter')
 _dn = _config('dn', conf)
 scope = _config('scope', conf)
 _lists = (_config('lists', conf) or [])
 _attrs = (_config('attrs', conf) or [])
 attrs = (_lists + _attrs)
 if (not attrs):
  attrs = None
 try:
  result = __salt__['ldap.search'](_filter, _dn, scope, attrs, **connargs)['results']
 except IndexError:
  log.debug('LDAP search returned no results for filter {0}'.format(_filter))
  result = {}
 except Exception:
  log.critical('Failed to retrieve pillar data from LDAP:\n', exc_info=True)
  return {}
 return result

def _do_search ( conf ) : connargs = { } for name in [ 'server' , 'port' , 'tls' , 'binddn' , 'bindpw' , 'anonymous' ] : connargs [ name ] = _config ( name , conf ) if ( connargs [ 'binddn' ] and connargs [ 'bindpw' ] ) : connargs [ 'anonymous' ] = False try : _filter = conf [ 'filter' ] except KeyError : raise SaltInvocationError ( 'missing filter' ) _dn = _config ( 'dn' , conf ) scope = _config ( 'scope' , conf ) _lists = ( _config ( 'lists' , conf ) or [ ] ) _attrs = ( _config ( 'attrs' , conf ) or [ ] ) attrs = ( _lists + _attrs ) if ( not attrs ) : attrs = None try : result = __salt__ [ 'ldap.search' ] ( _filter , _dn , scope , attrs , ** connargs ) [ 'results' ] except IndexError : log . debug ( 'LDAP search returned no results for filter {0}' . format ( _filter ) ) result = { } except Exception : log . critical ( 'Failed to retrieve pillar data from LDAP:\n' , exc_info = True ) return { } return result
builds connection and search arguments .