From ed1c550665d37e2a2449620a6332646702831fe1 Mon Sep 17 00:00:00 2001
From: Martin Goik <goik@hdm-stuttgart.de>
Date: Mon, 22 May 2023 14:02:24 +0200
Subject: [PATCH] Extending ldap code sample

---
 Doc/Sdi/Ldap/ldap.xml | 110 ++++++++++++++++++++----------------------
 1 file changed, 52 insertions(+), 58 deletions(-)

diff --git a/Doc/Sdi/Ldap/ldap.xml b/Doc/Sdi/Ldap/ldap.xml
index 42ff76b23..6cd7d158f 100644
--- a/Doc/Sdi/Ldap/ldap.xml
+++ b/Doc/Sdi/Ldap/ldap.xml
@@ -1445,76 +1445,70 @@ shadow:         files ldap</programlisting>
         </itemizedlist>
       </tip>
 
-      <para>The idea is reading <xref linkend="glo_LDAP"/> entries thereby
-      write corresponding attributes according to the following rules:</para>
+      <para>The expected output with respect to the given initial data should
+      resemble:</para>
+
+      <screen>ou=departments,dc=betrayer,dc=com
+  ou: {departments}
+  objectClass: {top, organizationalUnit}
+  -------------------------------------------------------
+    ou=software,ou=departments,dc=betrayer,dc=com
+      ou: {software}
+      objectClass: {top, organizationalUnit}
+      -------------------------------------------------------
+        ou=devel,ou=software,ou=departments,dc=betrayer,dc=com
+          ou: {devel}
+          objectClass: {top, organizationalUnit}
+          -------------------------------------------------------
+            uid=bean,ou=devel,ou=software,ou=departments,dc=betrayer,dc=com
+              uid: {bean}
+              mail: {bean@betrayer.com}
+              givenName: {Jim}
+              cn: {Jim Bean}
+              sn: {Bean}
+              objectClass: {top, person, organizationalPerson, inetOrgPerson, posixAccount}
+              userPassword: {{smd5}aXJ/beVAvL4D6Oi0TKp8c3z/a6Pg0Wxp}
+              gidNumber: 1000
+              homeDirectory: /home/bean
+              uidNumber: 1000
+              -------------------------------------------------------
+        ou=testing,ou=software,ou=departments,dc=betrayer,dc=com
+          ou: {testing}
+          objectClass: {top, organizationalUnit}
+          -------------------------------------------------------
+    ou=financial,ou=departments,dc=betrayer,dc=com
+      ou: {financial}
+      objectClass: {top, organizationalUnit}
+
+...</screen>
+
+      <para>Remarks:</para>
 
       <itemizedlist>
         <listitem>
-          <para>If an attribute is of binary type just output its name
-          omitting the value(s).</para>
-
-          <tip>
-            <para><classname
-            xlink:href="http://www.ldaptive.org/javadocs/org/ldaptive/LdapAttribute.html">LdapAttribute</classname>.<methodname
-            xlink:href="http://www.ldaptive.org/javadocs/org/ldaptive/LdapAttribute.html#isBinary()">isBinary()</methodname>
-            is your friend.</para>
-          </tip>
+          <para>Descend a given arbitrary LDAP tree recursively.</para>
         </listitem>
 
         <listitem>
-          <para>If an attribute is single valued write its name and value to
-          standard output.</para>
-
-          <tip>
-            <para>Read <classname
-            xlink:href="http://www.ldaptive.org/javadocs/org/ldaptive/LdapAttribute.html">LdapAttribute</classname>.<methodname
-            xlink:href="http://www.ldaptive.org/javadocs/org/ldaptive/LdapAttribute.html#getName()">getName()</methodname>,
-            <classname
-            xlink:href="http://www.ldaptive.org/javadocs/org/ldaptive/LdapAttribute.html">LdapAttribute</classname>.<methodname
-            xlink:href="http://www.ldaptive.org/javadocs/org/ldaptive/LdapAttribute.html#size()">size()</methodname>and
-            <classname
-            xlink:href="http://www.ldaptive.org/javadocs/org/ldaptive/LdapAttribute.html">LdapAttribute</classname>.<methodname
-            xlink:href="http://www.ldaptive.org/javadocs/org/ldaptive/LdapAttribute.html#getStringValue()">getStringValue()</methodname>.</para>
-          </tip>
+          <para>Indent according to each entries hierarchy level. In the above
+          example <code>ou=software,ou=departments,dc=betrayer,dc=com</code>
+          being a child of <code>ou=departments,dc=betrayer,dc=com</code>
+          receives an extra indent.</para>
         </listitem>
 
         <listitem>
-          <para>If an attribute is multivalued write its name and all values
-          among with a corresponding index to standard output.</para>
+          <para>Mind single and multi valuedness of attributes: In the above
+          example <code>mail: {bean@betrayer.com}</code> is multivalued in
+          contrast to <code>homeDirectory: /home/bean</code>. The brace pairs
+          {...} denote attribute sets. The server's schema information is your
+          friend. Consider the following hints:</para>
 
-          <tip>
-            <para>Read <classname
-            xlink:href="http://www.ldaptive.org/javadocs/org/ldaptive/LdapAttribute.html">LdapAttribute</classname>.<methodname
-            xlink:href="http://www.ldaptive.org/javadocs/org/ldaptive/LdapAttribute.html#getStringValues()">getStringValues()</methodname>
-            .</para>
-          </tip>
+          <programlisting language="java">ConnectionFactory factory = DefaultConnectionFactory ... ;
+Schema schema = SchemaFactory.createSchema(factory);
+
+... schema.getAttributeType(...).isSingleValued() ...</programlisting>
         </listitem>
       </itemizedlist>
-
-      <para>If your own binding <xref linkend="glo_DN"/> was
-      <code>uid=mistudent,ou=userlist,dc=hdm-stuttgart,dc=de</code> the result
-      should look like:</para>
-
-      <screen>mail: mistudent@mi.hdm-stuttgart.de
-gidNumber: 31104
-cn: MI Negative Testuser
-objectClass[0]: posixAccount
-objectClass[1]: hdmSambaDomain
-objectClass[2]: hdmAccount
-objectClass[3]: hdmStudent
-objectClass[4]: inetOrgPerson
-objectClass[5]: eduPerson
-objectClass[6]: shadowAccount
-loginShell: /bin/sh
-<emphasis role="bold">Not displaying value of binary attribute</emphasis> 'userPassword'
-hdmCategory: 1
-uid: mistudent
-uidNumber: 32669
-shadowLastChange: 16749
-homeDirectory: /home/stud/MI/mistudent
-sambaNTPassword: C1E13066AA936CBF9260913EE962B8C2
-sn: Testuser
-matrikelNr: 98911</screen>
     </section>
   </section>
 </chapter>
-- 
GitLab