While tryng to use OpenLDAP with the entries derived from
account and posixAccount the table editor would list uid and userid
both as manidory. This cause problems trying to add update
an entry.

But uid and userid are aliases names for the same attribute so this
is a table editor problem, as it treas these as separate "must" attributes.

Attached is a patch that gets around this problem in the table editor
by looking up the name in the schema then using the first alias found.

I must admit I am not much of a Java programmer so please review
this carefully. The intent is to look up the requested name in the attribute
schema and return the first name from that entry. It also gets the OID
so it can be registered for later use.  It then returns the first name.
Thus if userid was found, it would look this up and find it had uid
and userid  and would return uid.

The processing of the names in this area is very confusing.
There is a 42 line comment in the getldapName routine, and the use
of the variables names attOID when this is usually an Ldap name is
very confusing.

The patch is against the CVS.
  cvs -d:pserver:[EMAIL PROTECTED]:/cvsroot/jxplorer

Thnaks.

P.S.

The web page at  http://www.jxplorer.org/ under Download Source code
says:
  "The source code can be downloaded from sourceforge cvs via anonymous
   cvs - something like:
   cvs -d:pserver:[EMAIL PROTECTED]:/cvsroot/jxplorer
   should do it."
But that is wrong.

--

 Douglas E. Engert  <[EMAIL PROTECTED]>
 Argonne National Laboratory
 9700 South Cass Avenue
 Argonne, Illinois  60439
 (630) 252-5444
Index: src/com/ca/commons/naming/DXAttributes.java
===================================================================
RCS file: /cvsroot/jxplorer/javasrc/com/ca/commons/naming/DXAttributes.java,v
retrieving revision 1.13
diff -u -r1.13 DXAttributes.java
--- src/com/ca/commons/naming/DXAttributes.java 10 Aug 2005 07:27:14 -0000      
1.13
+++ src/com/ca/commons/naming/DXAttributes.java 28 Feb 2007 21:59:23 -0000
@@ -898,6 +898,7 @@
 
                         //XXX ;binary hack
                         if (attOID.indexOf(";binary")>0) attOID = 
attOID.substring(0,attOID.indexOf(";binary"));
+                        attOID = getldapAliasName(attOID); //DEE
 
                         String ldapName = getldapName(attOID);
 
@@ -924,6 +925,8 @@
                         //XXX isNonString hack
                         if (attOID.indexOf(";binary")>0) attOID = 
attOID.substring(0,attOID.indexOf(";binary"));
 
+                        attOID = getldapAliasName(attOID); //DEE
+
                         String ldapName = getldapName(attOID);
                         registerOID(attOID, ldapName);
 
@@ -956,6 +959,40 @@
     }
 
     /**
+     * <p>If a "must" name has an alias, like "o" and "organization", 
+     * or "uid" and "userid", and schemas like "account" and 
+     * "posixAccount" use different aliases in in different Objects
+     * and an entry has multiple ObjectTypes  we dont want to add 
+     * "uid" and "userid" as "must", as this will causes problems. 
+     * So we will check for the aliases, and use the first one. 
+     * If we can't find it, will just return the same name. DEE</p>
+     */ 
+
+    public String getldapAliasName(String attOID)
+    {
+    try
+    {
+        Attributes myldapEntry = schema.getAttributes("AttributeDefinition/" + 
attOID);
+        Attribute myOID = myldapEntry.get("OID");
+        NamingEnumeration myOIDs = myOID.getAll();
+        String myattOID = (String) myOIDs.next(); // get OID too
+
+        Attribute myname = myldapEntry.get("NAME");
+        NamingEnumeration mynames = myname.getAll();
+        String myattname = (String) mynames.next(); // get first name
+        //log.info("DEE **** myattOID: " + myattOID + " myattname: " + 
myattname);
+        registerOID(myattOID, myattname);
+        return myattname;
+    }
+    catch (Exception e)
+    {
+        log.info("getldapAliasName unable to map alias for:" + attOID +  e);
+    }
+    //log.info("DEE **** final attOID: " + attOID);
+    return attOID;
+    }
+
+    /**
      *    This method does it's darndnest to return a string ldap name.<p>
      *    First, it checks whether the string is <i>already</i> an ldap
      *    name; if it is, it returns it unchanged.<p>
@@ -1476,4 +1513,4 @@
 
 
 
-}
\ No newline at end of file
+}
Index: src/com/ca/directory/jxplorer/viewer/TableAttributeEditor.java
===================================================================
RCS file: 
/cvsroot/jxplorer/javasrc/com/ca/directory/jxplorer/viewer/TableAttributeEditor.java,v
retrieving revision 1.12
diff -u -r1.12 TableAttributeEditor.java
--- src/com/ca/directory/jxplorer/viewer/TableAttributeEditor.java      26 Oct 
2006 22:29:58 -0000      1.12
+++ src/com/ca/directory/jxplorer/viewer/TableAttributeEditor.java      28 Feb 
2007 21:59:23 -0000
@@ -679,6 +679,7 @@
             entry.expandAllAttributes();
             currentDN = entry.getDN();
 
+log.info("DEE **  entry being displayed:\n" + entry);
             tableData.insertAttributes(entry);
             popupTableTool.setDN(currentDN);    // Sets the DN in 
SmartPopupTableTool.
             myEditor.setDN(currentDN);          // Sets the DN in the 
attributeValueCellEditor which can be used to identify the entry that is being 
modified/
@@ -884,4 +885,4 @@
             promptForSave(false);
         }
     }
-}
\ No newline at end of file
+}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Jxplorer-devel mailing list
Jxplorer-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jxplorer-devel

Reply via email to