/** * Get back a session for the give user and credentials bound with Simple Bind */ public CoreSession getSession( Dn principalDn, byte[] credentials ) throws LdapException { synchronized ( this ) { if ( !started ) { throw new IllegalStateException( "Service has not started." ); } } BindOperationContext bindContext = new BindOperationContext( null ); bindContext.setCredentials( credentials ); bindContext.setDn( principalDn.apply( schemaManager ) ); bindContext.setInterceptors( getInterceptors( OperationEnum.BIND ) ); operationManager.bind( bindContext ); return bindContext.getSession(); }
/** * Get back a session for a given user bound with SASL Bind */ public CoreSession getSession( Dn principalDn, byte[] credentials, String saslMechanism, String saslAuthId ) throws Exception { synchronized ( this ) { if ( !started ) { throw new IllegalStateException( "Service has not started." ); } } BindOperationContext bindContext = new BindOperationContext( null ); bindContext.setCredentials( credentials ); bindContext.setDn( principalDn.apply( schemaManager ) ); bindContext.setSaslMechanism( saslMechanism ); bindContext.setInterceptors( getInterceptors( OperationEnum.BIND ) ); operationManager.bind( bindContext ); return bindContext.getSession(); }
/** * Try to authenticate the usr against the underlying LDAP server. */ private CoreSession authenticate( String user, String password ) throws InvalidNameException, Exception { BindOperationContext bindContext = new BindOperationContext( getLdapSession().getCoreSession() ); bindContext.setDn( new Dn( user ) ); bindContext.setCredentials( Strings.getBytesUtf8( password ) ); getAdminSession().getDirectoryService().getOperationManager().bind( bindContext ); return bindContext.getSession(); }
bindContext.setDn( bindDn ); bindContext.setInterceptors( directoryService.getInterceptors( OperationEnum.BIND ) );
/** * Used to encapsulate [de]marshalling of controls before and after bind operations. * * @param bindDn The user's Dn * @param credentials The credentials * @param saslMechanism The SASL mechanism to use * @param saslAuthId The SASL authorization ID * @return A BindOperationContext instance * @throws Exception If the Bind failed */ protected BindOperationContext doBindOperation( Dn bindDn, byte[] credentials, String saslMechanism, String saslAuthId ) throws Exception { // setup the op context and populate with request controls BindOperationContext bindContext = new BindOperationContext( null ); bindContext.setDn( bindDn ); bindContext.setCredentials( credentials ); bindContext.setSaslMechanism( saslMechanism ); bindContext.setSaslAuthId( saslAuthId ); bindContext.addRequestControls( convertControls( true, requestControls ) ); bindContext.setInterceptors( getDirectoryService().getInterceptors( OperationEnum.BIND ) ); // execute bind operation OperationManager operationManager = service.getOperationManager(); operationManager.bind( bindContext ); // clear the request controls and set the response controls requestControls = EMPTY_CONTROLS; responseControls = JndiUtils.toJndiControls( getDirectoryService().getLdapCodecService(), bindContext.getResponseControls() ); return bindContext; }
bindContext.setDn( userDn ); bindContext.setCredentials( oldPassword );
bindContext.setDn( bindRequest.getDn() ); bindContext.setCredentials( bindRequest.getCredentials() ); bindContext.setInterceptors( ldapSession.getLdapServer().getDirectoryService()
bindContext.setDn( bindRequest.getDn() ); bindContext.setCredentials( bindRequest.getCredentials() ); bindContext.setIoSession( ldapSession.getIoSession() );
bindContext.setDn( entry.getDn() ); bindContext.setCredentials( Strings.getBytesUtf8( password ) ); bindContext.setIoSession( ldapSession.getIoSession() );