key Log In or Register to edit

LDAP Plugin

This plugin provides an interface to query an LDAP directory and display the results in a TWiki topic. TWiki:Main.GerardHickey originally wrote this Plugin to pull data dynamically out of a corporate directory.

Features

  • Supports per-query filters
  • Supports retrieval and display of JPEG photos (e.g., personnel images)
  • Fields can be supplied through FORM links (see Examples below)
  • Fully configurable defaults

Examples

  • %LDAP{host="myldap.myco.com" base="ou=purchasing,o=MYCO" filter="employeenumber=00009707" format="$telephoneNumber"}%
  • %LDAP{host="myldap.myco.com" base="ou=finance,o=MYCO" filter="fullName=Johnson*" format="| $ou | $telephoneNumber |" header="| *Phone* | *OU* |"}%
  • %LDAP{format="Name : $cn <IMG SRC=$jpegPhoto width=100 > " header="" JPEGPHOTO="jpegPhoto"}%
  • The CGI parameter ldapfilter for the topic will be used as the filter for the LDAP query.
    • Put the following on a wiki page or form:
<FORM action="%SCRIPTURL%/view%SCRIPTSUFFIX%/%MAINWEB%/LdapPeople">
Filter: <input type="text" name="ldapfilter" size="25">
<input type="submit" value="LDAP Search" >
</FORM>
...and the Ldap People? page will be called up with your input as the filter.
  • Use this plugin on the T Wiki Registeration? topic to auto-fill in some or all fields.

LdapPlugin Setting Descriptions

Argument Comment Example
host LDAP host to query host="myldap.myco.com"
port LDAP port on host (if not set, defaults to 389) port="389"
base LDAP base base ="ou=Mydep,o=myco"
filter LDAP Search Filter filter="fullName=Gerald Skerbitz"
header Format of the Header for the query table header="*Phone*"
format Format of the data returned by the query.
Use $attribute for the fields.
Use the word FIELDLIST if you want a list of the valid fields in the LDAP database for the entry
format="|$fullName|$telephoneNumber|"
order Sort order order="sn,givenName"
mvformat Separater for multiple values mvformat="<LI>"
notfounderror Error message you want to get in case LDAP Plugin found nothing, useful to use LDAP to define Javascript vars (see T Wiki Ldap Registration?) notfounderror=""
jpegPhoto LDAP attribute keyname to extract photo, $jpegPhoto is then a URL to an image JPEGPHOTO="jpegPhoto"

LdapPlugin Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, for example, %LDAPPLUGIN_SHORTDESCRIPTION%

  • One line description, shown in the Text Formatting Rules topic:
  • Set SHORTDESCRIPTION = This plugin retrieves data from an LDAP directory and displays it on the current topic.

  • Set DEBUG to 1 to get debug messages in data/debug.txt. Default: 0
  • Set DEBUG = 0

  • LDAP host to connect to access the directory.
  • Set HOST = ldap.yourorganization.com

  • LDAP port on the above host
  • Set PORT = 389

  • The base DN to use for searching the LDAP directory.
  • Set BASE = ou=whatever,dc=yourorganization,dc=com

  • The default header for returning query data
  • Set HEADER =

  • The default format to use for returning data (similar to the Formatted Search)
  • Set FORMAT =

  • The default sort order
  • Set ORDER =

  • The default separator for multiple values
  • Set MVFORMAT =

  • Define the default LDAP attribute name for LDAP photo
  • Set JPEGPHOTO =

  • Define the default LDAP Photo for an LDAP entry without one
  • Set JPEGDEFAULTPHOTO =

  • Default filter (Note: If you set this to alias=TOPIC the word topic will be replaced with the TOPIC of the page on which the LDAP tag is located As an example, you can use the WIki username extracted from current TOPIC name to automatically display LDAP user information on any Wiki Home page.)
  • Set DEFAULTFILTER = "alias=TOPIC"

  • Not Found Error Message
  • Set NOTFOUNDERROR =

Limitations and Known Issues

  • Should have a limit parameter to limit the rows returned
  • Should have an offset parameter to enable partial listings and more control.

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.

  • Install the Net::LDAP module from CPAN or other source.
  • Download the ZIP file from the Plugin web (see below)
  • Unzip LdapPlugin.zip in your twiki installation directory. Content:
    File: Description:
    data/TWiki/LdapPlugin.txt Plugin topic
    data/TWiki/LdapPlugin.txt,v Plugin topic repository
    data/Sandbox/TestTopicLdapPlugin.txt,v Plugin topic repository
    lib/TWiki/Plugins/LdapPlugin.pm Plugin Perl module
  • (Dakar) Visit configure in your TWiki installation, and enable the plugin in the {Plugins} section.
  • Test if the installation was successful:
  • Visit the above examples at Sandbox.TestTopicLdapPlugin? page, modify it for your own LDAP server, and see if it renders correctly.

Plugin Info

Plugin Author: TWiki:Main.GerardHickey
Plugin Version: 03 Oct 2005 (V1.011)
Change History:  
03 Oct 2005 Reindented without tabs; fixes for Dakar, use strict -(TWiki:Main.JoanTouzet)
05 Apr 2004 Added sort Order - (TWiki:Main.GeraldSkerbitz)
04 Feb 2004 Code contributed by Patrick Nomblot? to accomodate multiple values per attribute - (TWiki:Main.GeraldSkerbitz)
02 Feb 2004 Code and doc cleanups -- basedn changed to base everywhere - (TWiki:Main.GeraldSkerbitz)
14 Jan 2004 CGI now allowed and Default filter set on Preferences page - (TWiki:Main.GeraldSkerbitz) & (TWiki:Main.PatrickNomblot)
13 Jan 2004 Added utf processing (another dependency!) - (TWiki:Main.GeraldSkerbitz)
09 Dec 2003 Changed Photo processing code to NOT include the IMG tag. This will break things for people doing photos!!!! - (TWiki:Main.GeraldSkerbitz)
27 Mar 2003 added LDAP photo extract / display.
added default FILTER definition (assigned on current TOPIC namme translated into username).
added possibilty to define error message in case no record is found.
intended to work (also) well with TWiki Ldap Registration. (TWiki:Main.PatrickNomblot)
24 Apr 2002 Modified to remove reference to show. Fields are now extracted from format - (TWiki:Main.GeraldSkerbitz)
23 Apr 2002 Modified to return multiple attributes and rows with formatting - (TWiki:Main.GeraldSkerbitz)
22 Apr 2002 Modified to use quoted strings in params - (TWiki:Main.GeraldSkerbitz)
11 Jan 2002 Initial version
CPAN Dependencies: Net::LDAP, Unicode::String
Other Dependencies: none
Perl Version: 5.0
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/LdapPlugin ( TWiki:Plugins/LdapPlugin )
Feedback: http://TWiki.org/cgi-bin/view/Plugins/LdapPluginDev ( TWiki:Plugins/LdapPluginDev )

Related Topics: T Wiki Preferences, T Wiki Plugins

-- TWiki:Main.JoanTouzet - 03 October 2005

 
Ad Sponsor
Back to Redbourn
Copyright © We make no guarantee of the correctness of the content of this site. All material on this collaboration platform is the property of Martin Cleaver and the contributing authors.