include::../common/rationale.adoc[] == Why is this an issue? include::../common/description.adoc[] === What is the potential impact? include::../common/impact.adoc[] == How to fix it === Code examples include::../common/fix/code-rationale.adoc[] ==== Noncompliant code example [source,java,diff-id=1,diff-type=noncompliant] ---- // Set up the environment for creating the initial context Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial"); // Use anonymous authentication env.put(Context.SECURITY_AUTHENTICATION, "none"); // Noncompliant // Create the initial context DirContext ctx = new InitialDirContext(env); ---- ==== Compliant solution [source,java,diff-id=1,diff-type=compliant] ---- // Set up the environment for creating the initial context Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=Example"); // Use simple authentication env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "cn=local, ou=Unit, o=Example"); env.put(Context.SECURITY_CREDENTIALS, getLDAPPassword()); // Create the initial context DirContext ctx = new InitialDirContext(env); ---- //=== How does this work? //=== Pitfalls //=== Going the extra mile == Resources //=== Documentation include::../common/resources/documentation.adoc[] //=== Articles & blog posts //=== Conference presentations //=== Standards include::../common/resources/standards.adoc[] //=== Benchmarks ifdef::env-github,rspecator-view[] ''' == Implementation Specification (visible only on this page) include::../message.adoc[] include::../highlighting.adoc[] endif::env-github,rspecator-view[]