26
26
*
27
27
* Portions Copyrighted 2010-2016 ForgeRock AS.
28
28
* Portions Copyrighted 2019 Open Source Solution Technology Corporation
29
+ * Portions Copyrighted 2024 3A Systems LLC
29
30
*/
30
31
31
32
package com .sun .identity .authentication .modules .ldap ;
56
57
import javax .security .auth .callback .NameCallback ;
57
58
import javax .security .auth .callback .PasswordCallback ;
58
59
60
+ import org .apache .commons .lang .StringUtils ;
59
61
import org .forgerock .openam .ldap .LDAPAuthUtils ;
60
62
import org .forgerock .openam .ldap .LDAPUtilException ;
61
63
import org .forgerock .openam .ldap .ModuleState ;
@@ -86,6 +88,8 @@ public class LDAP extends AMLoginModule {
86
88
private String regEx ;
87
89
private String currentConfigName ;
88
90
private String bindDN ;
91
+
92
+ private Boolean useBindingForAuth = false ;
89
93
private String protocolVersion ;
90
94
private int currentState ;
91
95
protected LDAPAuthUtils ldapUtil ;
@@ -113,7 +117,7 @@ enum LoginScreen {
113
117
ACCOUNT_LOCKED (5 , "accountLocked" );
114
118
115
119
private static final Map <Integer ,LoginScreen > lookup =
116
- new HashMap <Integer , LoginScreen >();
120
+ new HashMap <>();
117
121
118
122
static {
119
123
for (LoginScreen ls : EnumSet .allOf (LoginScreen .class )) {
@@ -180,9 +184,6 @@ public boolean initializeLDAP() throws AuthLoginException {
180
184
181
185
String baseDN = CollectionHelper .getServerMapAttr (
182
186
currentConfig , "iplanet-am-auth-ldap-base-dn" );
183
- if (baseDN == null ) {
184
- debug .error ("BaseDN for search was null" );
185
- }
186
187
187
188
String pLen = CollectionHelper .getMapAttr (currentConfig ,
188
189
"iplanet-am-auth-ldap-min-password-length" );
@@ -193,8 +194,14 @@ public boolean initializeLDAP() throws AuthLoginException {
193
194
debug .error ("LDAP.initializeLDAP : " + pLen , ex );
194
195
}
195
196
}
196
- bindDN = CollectionHelper .getMapAttr (currentConfig ,
197
- "iplanet-am-auth-ldap-bind-dn" , "" );
197
+
198
+ bindDN = CollectionHelper .getMapAttr (currentConfig , "iplanet-am-auth-ldap-bind-dn" , "" );
199
+
200
+ useBindingForAuth = StringUtils .isEmpty (bindDN );
201
+ if (baseDN == null && !useBindingForAuth ) {
202
+ debug .error ("BaseDN for search was null" );
203
+ }
204
+
198
205
char [] bindPassword = CollectionHelper .getMapAttr (
199
206
currentConfig , "iplanet-am-auth-ldap-bind-passwd" , "" ).toCharArray ();
200
207
String userNamingAttr = CollectionHelper .getMapAttr (
@@ -255,7 +262,7 @@ public boolean initializeLDAP() throws AuthLoginException {
255
262
256
263
isProfileCreationEnabled = isDynamicProfileCreationEnabled ();
257
264
// set the optional attributes here
258
- ldapUtil = new LDAPAuthUtils (primaryServers , secondaryServers , isSecure , bundle , baseDN , debug );
265
+ ldapUtil = new LDAPAuthUtils (primaryServers , secondaryServers , isSecure , bundle , baseDN , useBindingForAuth , debug );
259
266
ldapUtil .setScope (searchScope );
260
267
ldapUtil .setFilter (searchFilter );
261
268
ldapUtil .setUserNamingAttribute (userNamingAttr );
@@ -273,9 +280,11 @@ public boolean initializeLDAP() throws AuthLoginException {
273
280
ldapUtil .setHeartBeatTimeUnit (heartBeatTimeUnit );
274
281
ldapUtil .setOperationTimeout (operationTimeout );
275
282
ldapUtil .setProtocolVersion (protocolVersion );
283
+ ldapUtil .setUseBindingForAuth (useBindingForAuth );
276
284
277
285
if (debug .messageEnabled ()) {
278
286
debug .message ("bindDN-> " + bindDN
287
+ + "\n useBindingForAuth-> " + useBindingForAuth
279
288
+ "\n requiredPasswordLength-> " + requiredPasswordLength
280
289
+ "\n baseDN-> " + baseDN
281
290
+ "\n userNamingAttr-> " + userNamingAttr
0 commit comments