LDAP Plugin
<--
Contributions to this TWiki plugin are appreciated. Please update the plugin page at
http://twiki.org/cgi-bin/view/Plugins/LdapPlugin or provide feedback at
http://twiki.org/cgi-bin/view/Plugins/LdapPluginDev .
If you are a TWiki contributor please update the plugin in the SVN repository.
-->
Retrieve data from an LDAP directory to show in TWiki topics.
Introduction
This plugin was written by TWiki:Main.GerardHickey to allow data to be pulled out of an LDAP directory and displayed in a TWiki topic. See TWiki:Plugins.LdapNgPlugin for an alternative plugin.
Syntax Rules
LDAP directory search
Write the tag %LDAP{ parameters }% anywhere in a TWiki topic to define an LDAP directory search. Use the format="..." parameter to define the output format of the search result. Valid parameters are
Name |
Description |
Example |
host |
LDAP host to query |
host="ldap://ldap.example.org:389" |
starttls |
Perform StartTLS extended operation |
starttls="yes" |
base |
LDAP search base |
base="ou=People,o=example" |
filter |
LDAP search filter |
filter="(fullName=Gerald Skerbitz)" |
header |
Optional format of the header for the result table |
header="| *Name* | *Phone* |" |
format |
Format of the data returned by the search. Use $attribute for the fields. Use the word FIELDLIST if you want a list of the valid attributes in the LDAP directory for the data. |
format="| $sn, $givenName | $telephoneNumber |" |
mvformat |
Separator for multi-value attributes |
mvformat="<br />" |
order |
Sort order |
order="sn,givenName" |
reverse |
Reverse the order of the result set |
reverse="yes" |
skip |
Offset into the result set |
skip="75" |
limit |
Limit the number of rows returned |
limit="25" |
jpegphoto |
LDAP attribute to extract a JPEG photo. The field name, e.g. $jpegPhoto , will be replaced with a URL to an image. |
jpegphoto="jpegPhoto" |
jpegdefaultphoto |
URL of a default photo for an LDAP entry without a photo |
jpegdefaultphoto="/photos/default.jpg" |
notfounderror |
Error message you want to get in case LdapPlugin found nothing. Useful to define Javascript vars (see TWiki:Codev.TWikiLdapRegistration ) |
notfounderror="No contacts found" |
More examples
Search for a specific entry and return the value of the attribute telephoneNumber :
%LDAP{host="ldap.example.org" base="ou=purchasing,o=example" filter="(employeenumber=00009707)" format="$telephoneNumber"}%
Search for all entries where fullName begins with Johnson and output the result in a table:
%LDAP{host="ldap.example.org" base="ou=finance,o=example" filter="(fullName=Johnson*)" format="| $ou | $telephoneNumber |" header="| *OU* | *Phone* |"}%
Embed JPEG photos in the result:
%LDAP{format="Name: *$cn* <img src=\"$jpegPhoto\" width=\"100\" />" jpegphoto="jpegPhoto"}%
The CGI parameter ldapfilter can be used to define the filter for the LDAP search. Put the following on a wiki page:
<form action="%SCRIPTURL%/view%SCRIPTSUFFIX%/%MAINWEB%/LdapPeople">
Filter: <input type="text" name="ldapfilter" size="25" />
<input type="submit" value="LDAP Search" />
</form>
...and the LdapPeople page will be called up with your input as the filter.
LdapPlugin Settings
Plugin settings are stored as preferences variables. To reference
a plugin setting write %<plugin>_<setting>% , i.e. %LDAPPLUGIN_SHORTDESCRIPTION%
- One line description, shown in the TextFormattingRules topic:
- Set SHORTDESCRIPTION = Retrieve data from an LDAP directory to show in TWiki topics.
- LDAP host to connect to access the directory:
- Set HOST = ldap://ldap.example.org:389
- Perform StartTLS extended operation:
- Base DN to use for searching the LDAP directory:
- Set BASE = ou=whatever,dc=example,dc=org
- Default filter: (The string
TOPIC will be replaced in the default filter with the topic of the page on which the LDAP tag is located. That way you can use the Wiki username extracted from current topic name to automatically display LDAP user information from any Wiki Home page.)
- Default values:
- Set HEADER =
- Set FORMAT =
- Set MVFORMAT =
- Set ORDER =
- Set REVERSE =
- Set SKIP =
- Set LIMIT =
- Set JPEGPHOTO =
- Set JPEGDEFAULTPHOTO =
- Message displayed when a search returned no entries:
- Debug plugin: (See output in data/debug.txt)
Plugin Installation Instructions
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.
- Run configure for automated install, or do a manual install:
- Install the Net::LDAP module from CPAN or other source.
- Download the ZIP file from the Plugin web (see below). Contents:
File: | Description: | data/TWiki/LdapPlugin.txt | Plugin topic | lib/TWiki/Plugins/LdapPlugin.pm | Plugin Perl module |
- Unzip
LdapPlugin.zip in your twiki installation directory.
- Visit
configure in your TWiki installation, and enable the plugin in the {Plugins} section.
Plugin Info
Related Topics: TWikiPreferences, TWikiPlugins |