lprimak commented on code in PR #2309:
URL: https://github.com/apache/shiro/pull/2309#discussion_r2430800148


##########
core/src/main/java/org/apache/shiro/realm/activedirectory/ActiveDirectoryRealm.java:
##########
@@ -236,4 +232,12 @@ protected Collection<String> 
getRoleNamesForGroups(Collection<String> groupNames
         return roleNames;
     }
 
+    protected String getUsernameWithSuffix(String username) {
+        if (principalSuffix != null
+                && 
!username.toLowerCase(Locale.ROOT).endsWith(principalSuffix.toLowerCase(Locale.ROOT)))
 {
+            return username += principalSuffix;

Review Comment:
   ```suggestion
               return username + principalSuffix;
   ```



##########
core/src/main/java/org/apache/shiro/realm/activedirectory/ActiveDirectoryRealm.java:
##########
@@ -108,7 +108,7 @@ protected AuthenticationInfo 
queryForAuthenticationInfo(AuthenticationToken toke
         // Binds using the username and password provided by the user.
         LdapContext ctx = null;
         try {
-            ctx = ldapContextFactory.getLdapContext(upToken.getUsername(), 
String.valueOf(upToken.getPassword()));
+            ctx = 
ldapContextFactory.getLdapContext(getUsernameWithSuffix(upToken.getUsername()), 
String.valueOf(upToken.getPassword()));

Review Comment:
   ```suggestion
               ctx = 
ldapContextFactory.getLdapContext(getUsernameWithSuffix(upToken.getUsername()), 
                       String.valueOf(upToken.getPassword()));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to