Created
November 19, 2017 14:01
-
-
Save WeaponMan/faa417fea329a33f144d8362c9489bc4 to your computer and use it in GitHub Desktop.
Pure Java ldap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hashtable env = new Hashtable(11); | |
authEnv.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory"); | |
authEnv.put(Context.PROVIDER_URL, "ldap://ldap.example.com:389";); | |
authEnv.put(Context.SECURITY_AUTHENTICATION, "simple"); | |
authEnv.put(Context.SECURITY_PRINCIPAL, userName); | |
authEnv.put(Context.SECURITY_CREDENTIALS, passWord); | |
try { | |
DirContext authContext = new InitialDirContext(authEnv); | |
} catch (AuthenticationException authEx) { | |
System.out.println("Authentication failed!"); | |
} catch (NamingException namEx) { | |
System.out.println("Something went wrong!"); | |
namEx.PrintStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment