コード例 #1
0
 /**
  * Verifies the credential provided through LDAP server defined in config.properties
  *
  * @param credential specified username and password pairing
  * @return string output the values of the attributes defined in attrIds
  * @throws Exception authentication failed
  */
 public String authenticateUser(final Credential credential) throws Exception {
   try {
     final Hashtable<String, String> env =
         getEnvironmentTable(credential.getUsername(), credential.getPassword());
     DirContext ctx = new InitialDirContext(env);
     logger.info("authentication success");
     ctx.close();
     return ctx.toString();
   } catch (Exception e) {
     logger.error("Authentication failed: \n" + e.getMessage());
     throw new Exception("Authentication failed: \n" + e.getMessage());
   }
 }
コード例 #2
0
ファイル: LDAPInitialConf.java プロジェクト: jaigates/IB
 private void dirContextmethods() {
   System.out.println("Inside dirContextmethods");
   DirContext ctx = LDAPConstants.getLdapContext();
   String baseDN = "OU=Staff,OU=Accounts,O=ibo,DC=adld,DC=ibo,DC=org";
   DirContext schemaname;
   try {
     schemaname = ctx.getSchema(baseDN);
     System.out.println("schemaname-" + schemaname.toString());
   } catch (NamingException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }