diff --git a/src/main/scala/app/SystemSettingsController.scala b/src/main/scala/app/SystemSettingsController.scala index d1a813e..968875b 100644 --- a/src/main/scala/app/SystemSettingsController.scala +++ b/src/main/scala/app/SystemSettingsController.scala @@ -27,8 +27,8 @@ "ldap" -> optionalIfNotChecked("ldapAuthentication", mapping( "host" -> trim(label("LDAP host", text(required))), "port" -> trim(label("LDAP port", optional(number()))), - "bindDN" -> trim(label("Bind DN", text(required))), - "bindPassword" -> trim(label("Bind Password", text(required))), + "bindDN" -> trim(label("Bind DN", optional(text()))), + "bindPassword" -> trim(label("Bind Password", optional(text()))), "baseDN" -> trim(label("Base DN", text(required))), "userNameAttribute" -> trim(label("User name attribute", text(required))), "mailAttribute" -> trim(label("Mail address attribute", text(required))) diff --git a/src/main/scala/service/SystemSettingsService.scala b/src/main/scala/service/SystemSettingsService.scala index 4c01135..40c71eb 100644 --- a/src/main/scala/service/SystemSettingsService.scala +++ b/src/main/scala/service/SystemSettingsService.scala @@ -24,8 +24,8 @@ settings.ldap.map { ldap => props.setProperty(LdapHost, ldap.host) ldap.port.foreach(x => props.setProperty(LdapPort, x.toString)) - props.setProperty(LdapBindDN, ldap.bindDN) - props.setProperty(LdapBindPassword, ldap.bindPassword) + ldap.bindDN.foreach(x => props.setProperty(LdapBindDN, x)) + ldap.bindPassword.foreach(x => props.setProperty(LdapBindPassword, x)) props.setProperty(LdapBaseDN, ldap.baseDN) props.setProperty(LdapUserNameAttribute, ldap.userNameAttribute) props.setProperty(LdapMailAddressAttribute, ldap.mailAttribute) @@ -59,8 +59,8 @@ Some(Ldap( getValue(props, LdapHost, ""), getOptionValue(props, LdapPort, Some(DefaultLdapPort)), - getValue(props, LdapBindDN, ""), - getValue(props, LdapBindPassword, ""), + getOptionValue(props, LdapBindDN, None), + getOptionValue(props, LdapBindPassword, None), getValue(props, LdapBaseDN, ""), getValue(props, LdapUserNameAttribute, ""), getValue(props, LdapMailAddressAttribute, ""))) @@ -86,8 +86,8 @@ case class Ldap( host: String, port: Option[Int], - bindDN: String, - bindPassword: String, + bindDN: Option[String], + bindPassword: Option[String], baseDN: String, userNameAttribute: String, mailAttribute: String) diff --git a/src/main/scala/util/LDAPUtil.scala b/src/main/scala/util/LDAPUtil.scala index 1c02af9..96dd248 100644 --- a/src/main/scala/util/LDAPUtil.scala +++ b/src/main/scala/util/LDAPUtil.scala @@ -22,8 +22,8 @@ bind( ldapSettings.host, ldapSettings.port.getOrElse(SystemSettingsService.DefaultLdapPort), - ldapSettings.bindDN, - ldapSettings.bindPassword + ldapSettings.bindDN.getOrElse(""), + ldapSettings.bindPassword.getOrElse("") ) match { case Some(conn) => { withConnection(conn) { conn =>