Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/main/java/org/owasp/benchmark/helpers/LDAPManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,25 @@ protected Hashtable<Object, Object> createEnv() {
env.put(Context.PROVIDER_URL, "ldap://localhost:10389");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
env.put(Context.SECURITY_CREDENTIALS, "secret");

// Load password from environment variable or system property
String ldapPassword = System.getenv("LDAP_ADMIN_PASSWORD");
if (ldapPassword != null) {
ldapPassword = ldapPassword.trim();
}
if (ldapPassword == null || ldapPassword.isEmpty()) {
ldapPassword = System.getProperty("ldap.admin.password");
if (ldapPassword != null) {
ldapPassword = ldapPassword.trim();
}
if (ldapPassword == null || ldapPassword.isEmpty()) {
System.err.println(
"WARNING: Using default LDAP password. Set LDAP_ADMIN_PASSWORD environment variable or ldap.admin.password system property for secure configuration.");
ldapPassword = "secret";
}
}

env.put(Context.SECURITY_CREDENTIALS, ldapPassword);
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
return env;
}
Expand Down