0

I have to add Active Directory authorization in existing system. I have already been using Database Remote OS Authentication. I am in development phase right now. I have got various links for LDAP authorization and Authentication. As I want to implement only authorization so I would need only username for same. Moreover what parameters are required for initializing HashTable for DirContext in just AD Authorization

env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "LDAP://" + domain); 
env.put(Context.SECURITY_AUTHENTICATION, "EXTERNAL"); 
env.put(Context.SECURITY_PROTOCOL, "ssl");
env.put("javax.security.sasl.server.authentication", "true");
env.put(Context.SECURITY_PRINCIPAL, userId + "@" + domain); 
env.put(Context.SECURITY_CREDENTIALS, securityToken);
ctx = new InitialDirContext(env);

SearchResult srLdapUser = this.findAccountByAccountName(ctx, ldapSearchBase, userId);

Please suggest what do I pass in HashTable for just Authorization through LDAP, the above code is having some additional properties required for LDAP Authentication.

coderzzz18
  • 2,535
  • 5
  • 16
  • 23
  • It depends but I'd suggest `Hashtable env = new Hashtable(11);` to setup the environment for creating the initial context. – EricLavault Jan 09 '20 at 12:27
  • Can I get initial context without passing password here? @EricLavault – coderzzz18 Jan 13 '20 at 06:11
  • No need to pass anything in this call. Or if you meant without SECURITY_CREDENTIALS, it depends on SECURITY_AUTHENTICATION which is set twice in your code. – EricLavault Jan 13 '20 at 07:37

0 Answers0