Bind with binddn and bindpw only for searching LDAP
    :param anonymous: Try binding anonymously
    :param opts: Pass in when __opts__ is not available
    :return: LDAPConnection object
427399
def _bind_for_search(anonymous=False, opts=None):
    '''
    
    '''
    # Get config params; create connection dictionary
    connargs = {}
    # config params (auth.ldap.*)
    params = {
        'mandatory': ['uri', 'server', 'port', 'starttls', '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

    # Only add binddn/bindpw to the connargs when they're set, as they're not
    # mandatory for initializing the LDAP object, but if they're provided
    # initially, a bind attempt will be done during the initialization to
    # validate them
    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']:
            # search for the user's DN to be used for the actual authentication
            return _LDAPConnection(**connargs).ldap
1009437
def _config(key, mandatory=True, opts=None):
    '''
    
    '''
    try:
        if opts:
            value = opts['auth.ldap.{0}'.format(key)]
        else:
            value = __opts__['auth.ldap.{0}'.format(key)]
    except KeyError:
        try:
            value = __defopts__['auth.ldap.{0}'.format(key)]
        except KeyError:
            if mandatory:
                msg = 'missing auth.ldap.{0} in master config'.format(key)
                raise SaltInvocationError(msg)
            return False
    return value
363929
def get_bind(self, mapper=None, clause=None):
        
        # mapper is None if someone tries to just get a connection
        if mapper is not None:
            try:
                # SA >= 1.3
                persist_selectable = mapper.persist_selectable
            except AttributeError:
                # SA < 1.3
                persist_selectable = mapper.mapped_table

            info = getattr(persist_selectable, 'info', {})
            bind_key = info.get('bind_key')
            if bind_key is not None:
                state = get_state(self.app)
                return state.db.get_engine(self.app, bind=bind_key)
        return SessionBase.get_bind(self, mapper, clause)
802380
function opt (option) {
  return function (value) {
    if (typeof value === 'undefined') {
      return nn.Getopt(this.binding, nn.NN_SOL_SOCKET, sol[option]);
    }

    if(nn.Setopt(this.binding, nn.NN_SOL_SOCKET, sol[option], value) > -1) {
      return true;
    }

    throw new Error(nn.Err() + ': ' + this.type + option + '@' + value + '\n');
  }
}
104123
def _search_for_user_dn(self):
        
        search = self.settings.USER_SEARCH
        if search is None:
            raise ImproperlyConfigured(
                "AUTH_LDAP_USER_SEARCH must be an LDAPSearch instance."
            )

        results = search.execute(self.connection, {"user": self._username})
        if results is not None and len(results) == 1:
            (user_dn, self._user_attrs) = next(iter(results))
        else:
            user_dn = None

        return user_dn
533179
function _connect( $host, $username, $password, $ldapbase)
	{
		global $LDAP_CONNECT_OPTIONS;

		if ( !function_exists( 'ldap_connect' ) ) return null;

		if (strpos($host,'ldap://') === 0 || strpos($host,'ldaps://') === 0) {
			$this->_connectionID = @ldap_connect($host);
		} else {
			$conn_info = array( $host,$this->port);

			if ( strstr( $host, ':' ) ) {
				$conn_info = explode( ':', $host );
			}

			$this->_connectionID = @ldap_connect( $conn_info[0], $conn_info[1] );
		}
		if (!$this->_connectionID) {
			$e = 'Could not connect to ' . $conn_info[0];
			$this->_errorMsg = $e;
			if ($this->debug) ADOConnection::outp($e);
			return false;
		}
		if( count( $LDAP_CONNECT_OPTIONS ) > 0 ) {
			$this->_inject_bind_options( $LDAP_CONNECT_OPTIONS );
		}

		if ($username) {
			$bind = @ldap_bind( $this->_connectionID, $username, $password );
		} else {
			$username = 'anonymous';
			$bind = @ldap_bind( $this->_connectionID );
		}

		if (!$bind) {
			$e = sprintf($this->_bind_errmsg,ldap_error($this->_connectionID));
			$this->_errorMsg = $e;
			if ($this->debug) ADOConnection::outp($e);
			return false;
		}
		$this->_errorMsg = '';
		$this->database = $ldapbase;
		return $this->_connectionID;
	}
283906
public static vpnglobal_authenticationldappolicy_binding[] get_filtered(nitro_service service, String filter) throws Exception{
		vpnglobal_authenticationldappolicy_binding obj = new vpnglobal_authenticationldappolicy_binding();
		options option = new options();
		option.set_filter(filter);
		vpnglobal_authenticationldappolicy_binding[] response = (vpnglobal_authenticationldappolicy_binding[]) obj.getfiltered(service, option);
		return response;
	}
577058
def bind(self, source, dest, destmeth):
        
        self.connect(source, getattr(dest, destmeth))
1367837
def find_bind_module(name, verbose=False):
    
    bindnames = get_bind_modules(verbose=verbose)
    bindfile = bindnames.get(name)

    if bindfile:
        return bindfile

    if not verbose:
        return None

    # suggest close matches
    fuzzy_matches = get_close_pkgs(name, bindnames.keys())

    if fuzzy_matches:
        rows = [(x[0], bindnames[x[0]]) for x in fuzzy_matches]
        print "'%s' not found. Close matches:" % name
        print '\n'.join(columnise(rows))
    else:
        print "No matches."

    return None
1017885
def _bind(self, args, kwds):
    """"""
    bindings = dict(kwds)
    for i, arg in enumerate(args):
      bindings[i + 1] = arg
    used = {}
    ancestor = self.ancestor
    if isinstance(ancestor, ParameterizedThing):
      ancestor = ancestor.resolve(bindings, used)
    filters = self.filters
    if filters is not None:
      filters = filters.resolve(bindings, used)
    unused = []
    for i in xrange(1, 1 + len(args)):
      if i not in used:
        unused.append(i)
    if unused:
      raise datastore_errors.BadArgumentError(
          'Positional arguments %s were given but not used.' %
          ', '.join(str(i) for i in unused))
    return self.__class__(kind=self.kind, ancestor=ancestor,
                          filters=filters, orders=self.orders,
                          app=self.app, namespace=self.namespace,
                          default_options=self.default_options,
                          projection=self.projection, group_by=self.group_by)
71638
def get_conn(cls):
        """"""
        conn = cls._conn
        if conn is None or conn.closed:
            conn = ldap3.Connection(
                settings.CAS_LDAP_SERVER,
                settings.CAS_LDAP_USER,
                settings.CAS_LDAP_PASSWORD,
                client_strategy="RESTARTABLE",
                auto_bind=True
            )
            cls._conn = conn
        return conn
748669
def get_ldap(cls, global_options=None):
        
        if cls.ldap is None:
            import ldap.filter

            # Support for python-ldap < 2.0.6
            try:
                import ldap.dn
            except ImportError:
                from django_auth_ldap import dn
                ldap.dn = dn

            cls.ldap = ldap

        # Apply global LDAP options once
        if (not cls._ldap_configured) and (global_options is not None):
            for opt, value in global_options.items():
                cls.ldap.set_option(opt, value)

            cls._ldap_configured = True

        return cls.ldap
903986
function Link (opts) {
  if(!opts) opts = {}
  this.timeout = opts.timeout || 10*SECONDS
  this.localTransmissionId = 0
  this.lastRemoteTransmissionId = null
  this.credentials = opts.credentials
  this.authenticateFn = opts.authenticate
  this.authorizeReadFn = opts.authorizeRead
  this.authorizeWriteFn = opts.authorizeWrite
  this.authenticated
  this.sentEdit
  this.sentRequestInit
  this.queue
  this.linkBuffer = ''

  Duplex.call(this, {allowHalfOpen: false, objectMode: true})

  this.on('error', function(er) {
    debug('Error in link', 'undefined'!=typeof window? er : er.stack || er)
  }.bind(this))

  this.on('editError', function(er) {
    debug('EditError in link', 'undefined'!=typeof window? er : er.stack || er)
  })

  this.reset()
}
839885
def search(self, filter, base_dn=None, attrs=None, scope=None,
               timeout=None, limit=None):
        
        if base_dn is None:
            base_dn = self._search_defaults.get('base_dn', '')
        if attrs is None:
            attrs = self._search_defaults.get('attrs', None)
        if scope is None:
            scope = self._search_defaults.get('scope', ldap.SCOPE_SUBTREE)
        if timeout is None:
            timeout = self._search_defaults.get('timeout', -1)
        if limit is None:
            limit = self._search_defaults.get('limit', 0)

        results = self.connection.search_ext_s(
            base_dn, scope, filter, attrs, timeout=timeout, sizelimit=limit)
        return self.to_items(results)
1168345
def bind(self):
        

        conn = self.initialize
        try:
            conn.simple_bind_s(
                current_app.config['LDAP_USERNAME'],
                current_app.config['LDAP_PASSWORD'])
            return conn
        except ldap.LDAPError as e:
            raise LDAPException(self.error(e.args))
357114
def bind(cls, app, *paths, methods=None, name=None, router=None, view=None):
        """"""
        cls.app = app
        if cls.app is not None:
            for _, m in inspect.getmembers(cls, predicate=inspect.isfunction):
                if not hasattr(m, ROUTE_PARAMS_ATTR):
                    continue
                paths_, methods_, name_ = getattr(m, ROUTE_PARAMS_ATTR)
                name_ = name_ or ("%s.%s" % (cls.name, m.__name__))
                delattr(m, ROUTE_PARAMS_ATTR)
                cls.app.register(*paths_, methods=methods_, name=name_, handler=cls)(m)

        @coroutine
        @functools.wraps(cls)
        def handler(request):
            return cls().dispatch(request, view=view)

        if not paths:
            paths = ["/%s" % cls.__name__]

        return routes_register(
            app, handler, *paths, methods=methods, router=router, name=name or cls.name)
972714
def bind_filter(self, direction, filter_name):
        

        if direction not in self._dynamips_direction:
            raise DynamipsError("Unknown direction {} to bind filter {}:".format(direction, filter_name))
        dynamips_direction = self._dynamips_direction[direction]

        yield from self._hypervisor.send("nio bind_filter {name} {direction} {filter}".format(name=self._name,
                                                                                              direction=dynamips_direction,
                                                                                              filter=filter_name))

        if direction == "in":
            self._input_filter = filter_name
        elif direction == "out":
            self._output_filter = filter_name
        elif direction == "both":
            self._input_filter = filter_name
            self._output_filter = filter_name