Copyright (c) 2001, Junzo SATO. All rights reserved.

Using LDAP from Mathematica, Part 2

To learn LDAP from the book "LDAP Programming with Java", J/Link was very convenient tool. I learned how to write Java program for LDAP. At the same time, Mathematica has got functionality to use LDAP.

Junzo SATO

Aug 13th 2001

Installing J/Link

J/Link Mathmatica package is loaded.

[Graphics:Images/ldapdoc02_gr_1.gif]

InstallJava[ ] setups J/Link environment so that the Mathmatica can use Java. Options varies depending on which machine and operating system a user is using.

[Graphics:Images/ldapdoc02_gr_2.gif]
[Graphics:Images/ldapdoc02_gr_3.gif]
[Graphics:Images/ldapdoc02_gr_4.gif]

Initializing LDAP Connection

Tools

[Graphics:Images/ldapdoc02_gr_5.gif]
[Graphics:Images/ldapdoc02_gr_6.gif]
[Graphics:Images/ldapdoc02_gr_7.gif]
[Graphics:Images/ldapdoc02_gr_8.gif]

A connection to the LDAP server is established. By default, LDAP server uses port number 389.

Initializing LDAP Connection

Connection to the LDAP server is created. In this example, localhost is used for convenience.

[Graphics:Images/ldapdoc02_gr_9.gif]
[Graphics:Images/ldapdoc02_gr_10.gif]
[Graphics:Images/ldapdoc02_gr_11.gif]
[Graphics:Images/ldapdoc02_gr_12.gif]
[Graphics:Images/ldapdoc02_gr_13.gif]
[Graphics:Images/ldapdoc02_gr_14.gif]

Controlling Entry

Tools are loaded and defined.

[Graphics:Images/ldapdoc02_gr_15.gif]
[Graphics:Images/ldapdoc02_gr_16.gif]
[Graphics:Images/ldapdoc02_gr_17.gif]
[Graphics:Images/ldapdoc02_gr_18.gif]

Search by filter.

[Graphics:Images/ldapdoc02_gr_19.gif]
[Graphics:Images/ldapdoc02_gr_20.gif]
[Graphics:Images/ldapdoc02_gr_21.gif]
[Graphics:Images/ldapdoc02_gr_22.gif]
[Graphics:Images/ldapdoc02_gr_23.gif]
[Graphics:Images/ldapdoc02_gr_24.gif]
[Graphics:Images/ldapdoc02_gr_25.gif]

The above result is the same as the one that LDAP Editor/Browser has retrieved.

[Graphics:Images/ldapdoc02_gr_26.gif]

Read by DN.

Null password for authentication means anonymous connection.

[Graphics:Images/ldapdoc02_gr_27.gif]
[Graphics:Images/ldapdoc02_gr_28.gif]
[Graphics:Images/ldapdoc02_gr_29.gif]
[Graphics:Images/ldapdoc02_gr_30.gif]
[Graphics:Images/ldapdoc02_gr_31.gif]
[Graphics:Images/ldapdoc02_gr_32.gif]
[Graphics:Images/ldapdoc02_gr_33.gif]
[Graphics:Images/ldapdoc02_gr_34.gif]

Compare

[Graphics:Images/ldapdoc02_gr_35.gif]
[Graphics:Images/ldapdoc02_gr_36.gif]
[Graphics:Images/ldapdoc02_gr_37.gif]
[Graphics:Images/ldapdoc02_gr_38.gif]
[Graphics:Images/ldapdoc02_gr_39.gif]
[Graphics:Images/ldapdoc02_gr_40.gif]

Client-side Sort

[Graphics:Images/ldapdoc02_gr_41.gif]
[Graphics:Images/ldapdoc02_gr_42.gif]
[Graphics:Images/ldapdoc02_gr_43.gif]
[Graphics:Images/ldapdoc02_gr_44.gif]
[Graphics:Images/ldapdoc02_gr_45.gif]
[Graphics:Images/ldapdoc02_gr_46.gif]
[Graphics:Images/ldapdoc02_gr_47.gif]
[Graphics:Images/ldapdoc02_gr_48.gif]
[Graphics:Images/ldapdoc02_gr_49.gif]
[Graphics:Images/ldapdoc02_gr_50.gif]
[Graphics:Images/ldapdoc02_gr_51.gif]
[Graphics:Images/ldapdoc02_gr_52.gif]
[Graphics:Images/ldapdoc02_gr_53.gif]
[Graphics:Images/ldapdoc02_gr_54.gif]
[Graphics:Images/ldapdoc02_gr_55.gif]
[Graphics:Images/ldapdoc02_gr_56.gif]
[Graphics:Images/ldapdoc02_gr_57.gif]
[Graphics:Images/ldapdoc02_gr_58.gif]
[Graphics:Images/ldapdoc02_gr_59.gif]
[Graphics:Images/ldapdoc02_gr_60.gif]
[Graphics:Images/ldapdoc02_gr_61.gif]
[Graphics:Images/ldapdoc02_gr_62.gif]
[Graphics:Images/ldapdoc02_gr_63.gif]
[Graphics:Images/ldapdoc02_gr_64.gif]
[Graphics:Images/ldapdoc02_gr_65.gif]
[Graphics:Images/ldapdoc02_gr_66.gif]
[Graphics:Images/ldapdoc02_gr_67.gif]
[Graphics:Images/ldapdoc02_gr_68.gif]
[Graphics:Images/ldapdoc02_gr_69.gif]
[Graphics:Images/ldapdoc02_gr_70.gif]
[Graphics:Images/ldapdoc02_gr_71.gif]
[Graphics:Images/ldapdoc02_gr_72.gif]
[Graphics:Images/ldapdoc02_gr_73.gif]
[Graphics:Images/ldapdoc02_gr_74.gif]
[Graphics:Images/ldapdoc02_gr_75.gif]
[Graphics:Images/ldapdoc02_gr_76.gif]
[Graphics:Images/ldapdoc02_gr_77.gif]
[Graphics:Images/ldapdoc02_gr_78.gif]
[Graphics:Images/ldapdoc02_gr_79.gif]
[Graphics:Images/ldapdoc02_gr_80.gif]
[Graphics:Images/ldapdoc02_gr_81.gif]
[Graphics:Images/ldapdoc02_gr_82.gif]
[Graphics:Images/ldapdoc02_gr_83.gif]
[Graphics:Images/ldapdoc02_gr_84.gif]
[Graphics:Images/ldapdoc02_gr_85.gif]
[Graphics:Images/ldapdoc02_gr_86.gif]
[Graphics:Images/ldapdoc02_gr_87.gif]
[Graphics:Images/ldapdoc02_gr_88.gif]
[Graphics:Images/ldapdoc02_gr_89.gif]
[Graphics:Images/ldapdoc02_gr_90.gif]
[Graphics:Images/ldapdoc02_gr_91.gif]
[Graphics:Images/ldapdoc02_gr_92.gif]
[Graphics:Images/ldapdoc02_gr_93.gif]
[Graphics:Images/ldapdoc02_gr_94.gif]
[Graphics:Images/ldapdoc02_gr_95.gif]
[Graphics:Images/ldapdoc02_gr_96.gif]
[Graphics:Images/ldapdoc02_gr_97.gif]
[Graphics:Images/ldapdoc02_gr_98.gif]
[Graphics:Images/ldapdoc02_gr_99.gif]
[Graphics:Images/ldapdoc02_gr_100.gif]
[Graphics:Images/ldapdoc02_gr_101.gif]
[Graphics:Images/ldapdoc02_gr_102.gif]
[Graphics:Images/ldapdoc02_gr_103.gif]
[Graphics:Images/ldapdoc02_gr_104.gif]
[Graphics:Images/ldapdoc02_gr_105.gif]
[Graphics:Images/ldapdoc02_gr_106.gif]
[Graphics:Images/ldapdoc02_gr_107.gif]
[Graphics:Images/ldapdoc02_gr_108.gif]
[Graphics:Images/ldapdoc02_gr_109.gif]
[Graphics:Images/ldapdoc02_gr_110.gif]
[Graphics:Images/ldapdoc02_gr_111.gif]
[Graphics:Images/ldapdoc02_gr_112.gif]
[Graphics:Images/ldapdoc02_gr_113.gif]
[Graphics:Images/ldapdoc02_gr_114.gif]
[Graphics:Images/ldapdoc02_gr_115.gif]
[Graphics:Images/ldapdoc02_gr_116.gif]
[Graphics:Images/ldapdoc02_gr_117.gif]
[Graphics:Images/ldapdoc02_gr_118.gif]
[Graphics:Images/ldapdoc02_gr_119.gif]
[Graphics:Images/ldapdoc02_gr_120.gif]
[Graphics:Images/ldapdoc02_gr_121.gif]
[Graphics:Images/ldapdoc02_gr_122.gif]
[Graphics:Images/ldapdoc02_gr_123.gif]
[Graphics:Images/ldapdoc02_gr_124.gif]
[Graphics:Images/ldapdoc02_gr_125.gif]
[Graphics:Images/ldapdoc02_gr_126.gif]
[Graphics:Images/ldapdoc02_gr_127.gif]
[Graphics:Images/ldapdoc02_gr_128.gif]
[Graphics:Images/ldapdoc02_gr_129.gif]
[Graphics:Images/ldapdoc02_gr_130.gif]
[Graphics:Images/ldapdoc02_gr_131.gif]
[Graphics:Images/ldapdoc02_gr_132.gif]
[Graphics:Images/ldapdoc02_gr_133.gif]
[Graphics:Images/ldapdoc02_gr_134.gif]

Add NEW Entry

[Graphics:Images/ldapdoc02_gr_135.gif]
[Graphics:Images/ldapdoc02_gr_136.gif]

The NEW entry is added successfully. For simplicity, new entry is added under the ou=Special Users directory.

[Graphics:Images/ldapdoc02_gr_137.gif]

Add Attribute

AddAttribute[conn,dn,attrname,data] adds an attribute to the existing entry. If the data is exactly same value as the existing attribute, it fails.

[Graphics:Images/ldapdoc02_gr_138.gif]
[Graphics:Images/ldapdoc02_gr_139.gif]

New attribute (multivalued attribute) is added successfully.

[Graphics:Images/ldapdoc02_gr_140.gif]

Replace Attribute

[Graphics:Images/ldapdoc02_gr_141.gif]
[Graphics:Images/ldapdoc02_gr_142.gif]

Attribute(s) named "mail" is replaced with new data.

[Graphics:Images/ldapdoc02_gr_143.gif]

It's possible to replace attribute(s) with multivalues.

[Graphics:Images/ldapdoc02_gr_144.gif]

The following figure shows the entry after replacement.

[Graphics:Images/ldapdoc02_gr_145.gif]

Delete Attribute

[Graphics:Images/ldapdoc02_gr_146.gif]
[Graphics:Images/ldapdoc02_gr_147.gif]

Surely removed :-)

[Graphics:Images/ldapdoc02_gr_148.gif]

ModificationSet

[Graphics:Images/ldapdoc02_gr_149.gif]
[Graphics:Images/ldapdoc02_gr_150.gif]

Two mails are listed as the result of first modification. The telephoneNumber is removed by replacing old attribute with null. One more mail is added by the final modification.

[Graphics:Images/ldapdoc02_gr_151.gif]

Finalizing LDAP Connection

Connection to the LDAP server is closed.This is essentially the same as ldapconn@finalize[].

[Graphics:Images/ldapdoc02_gr_152.gif]

Removing J/Link

[Graphics:Images/ldapdoc02_gr_153.gif]
[Graphics:Images/ldapdoc02_gr_154.gif]
[Graphics:Images/ldapdoc02_gr_155.gif]

Reference

[1] Rob Weltman and Tony Dahbura, "LDAP Programming with Java", Addison-Wesley, 2000


Converted by Mathematica      August 13, 2001