[ 
https://issues.apache.org/jira/browse/KNOX-3562?focusedWorklogId=1054840&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1054840
 ]

ASF GitHub Bot logged work on KNOX-3562:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 15/Nov/26 09:58
            Start Date: 15/Nov/26 09:58
    Worklog Time Spent: 10m 
      Work Description: smolnar82 commented on code in PR #1504:
URL: https://github.com/apache/knox/pull/1504#discussion_r4577913907


##########
gateway-server/src/main/java/org/apache/knox/gateway/services/ldap/KnoxLDAPServerManager.java:
##########
@@ -527,10 +528,11 @@ private void createBaseEntriesForDn(SchemaManager 
schemaManager, String dn) thro
         if (!directoryService.getAdminSession().exists(baseDnName)) {
             Entry baseDnEntry = new DefaultEntry(schemaManager);
             baseDnEntry.setDn(baseDnName);
-            baseDnEntry.add("objectClass", "top", "domain");
-            // Extract dc value from baseDn (e.g., "dc=proxy,dc=com" -> 
"proxy")
-            String dcValue = dn.split(",")[0].split("=")[1];
-            baseDnEntry.add("dc", dcValue);
+            String type = baseDnName.getRdn().getType();
+            String name = baseDnName.getRdn().getName();
+            String objectClass = getConventionalObjectClassFromType(type);
+            baseDnEntry.add("objectClass", "top", objectClass, 
"extensibleObject");
+            baseDnEntry.add(type, name);

Review Comment:
   `Rdn.getName()` returns the whole user-provided RDN (`ou=engineering`), not 
just the value, so the entry ends up with two values:
   
   ```
   ou: engineering      <- added by ApacheDS from the RDN
   ou: ou=engineering   <- added here
   ```
   
   The same happens for `o`, `cn`, `l` and `uid` (`dc` and `c` happen to come 
out clean). Since these base entries are only created when missing, the bad 
value would stick around in existing deployments even after a later fix.
   
   Could you use `getRdn().getValue()` instead, or just drop the 
`baseDnEntry.add(type, name)` call, since ApacheDS adds the RDN attribute 
itself?
   
   Please also assert the attribute values in `verifyRemoteBaseDnHandling`, 
e.g. that `entry.get(type)` has exactly one value equal to the RDN value; 
checking only the objectClass doesn't catch this.
   
   This came in with the latest commit (4a974f36b); before that, only the 
objectClass was set and ApacheDS filled in the RDN attribute correctly.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 1054840)
    Time Spent: 50m  (was: 40m)

> Accept cn for backend search base dn
> ------------------------------------
>
>                 Key: KNOX-3562
>                 URL: https://issues.apache.org/jira/browse/KNOX-3562
>             Project: Apache Knox
>          Issue Type: Bug
>          Components: LDAP
>    Affects Versions: 3.0.0
>            Reporter: David Han
>            Assignee: David Han
>            Priority: Major
>             Fix For: 3.1.0
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> The LDAP Proxy creates base entries for the configured backend DNs. The code 
> is limited to handling dc values only. The LDAP Proxy doesn't really care 
> what the value of the backend base DN is since it's passed on through to the 
> backend. We do need to create the DN in the LDAP Proxy so that the searches 
> for the backend DN are accepted. Loosen the restrictions on DN to accept cn 
> values as well.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to