/** * 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(); }
session = bindContext.getSession();
props.getSaslMechanism(), props.getSaslAuthId() ); session = bindContext.getSession(); OperationManager operationManager = service.getOperationManager();
CoreSession session = bindContext.getSession(); Dn bindDn = bindContext.getDn(); bindContext.getSession().setPwdMustChange( true );
ldapSession.setCoreSession( bindContext.getSession() );
CoreSession coreSession = bindContext.getSession(); ldapSession.setCoreSession( coreSession );
return bindContext.getSession();