|
Cookbook /
PhonebookSummary: Integrate LDAP information in the Profiles pages and use it as a corporate phonebook
Version: 0.3
Prerequisites: pmwiki 2.1
Status: Production
Maintainer: TjeerdVanDerLaan
Questions answered by this recipeIn our network we use an LDAP directory (or Active Directory) as a central repository for user information. After I've implemented single sign-on for my PmWiki based intranet I would like to integrate our LDAP directory information in PmWiki so that it adds some kind of corporate phonebook to PmWiki. DescriptionThis recipe synchronizes the Profiles pages with users in the LDAP directory. When new users are added the Profiles pages are automatically added. Information like telephone numbers is automatically refreshed in existing pages. Finally when users are deleted the Profiles pages are accordingly deleted. Additionally some page variables are added to be able to use the LDAP information in pages (or the Profiles.GroupHeader? page). InstallationPut Add the following lines to your
SDV($Phonebook_GroupName, 'Profiles');
SDV($Phonebook_LdapServer,'ldap://dc.internal.services');
SDV($Phonebook_LdapUser,'username@internal.services');
SDV($Phonebook_LdapPass,'password');
SDV($Phonebook_BaseDn,'dc=internal,dc=services');
SDV($Phonebook_Filter,'(&(objectClass=user)(objectClass=person)
(telephonenumber=*)(|(homeMDB=*)(msExchHomeServerName=*))
(!(objectClass=computer))(!(description=Disabled*)))');
SDV($Phonebook_Title,'cn');
SDV($Phonebook_Fields, Array('cn','sn','givenname','description','title',
'initials','department','mail','telephonenumber',
'physicaldeliveryofficename','samaccountname','mobile'));
SDV($Phonebook_Interval,3600); // cleanup pages every hour
include_once("$FarmD/cookbook/phonebook.php");
For each of the fields specified a page variable is created like
(:title {$ldap_cn}:)
%rframe height=140px% Attach:{$ldap_samaccountname}.jpg
||width:40%
||Title:||{$ldap_title} ||
||Name:||{$ldap_sn} ||
||First name:||{$ldap_givenname} ||
||Job title:||{$ldap_description} ||
||Department:||{$ldap_department} ||
||Telephone:||{$ldap_telephonenumber} ||
||Room:||{$ldap_physicaldeliveryofficename} ||
||Mobile:||{$ldap_mobile} ||
----
By standard PmWiki only searches the target and text fields of the pages. This recipe adds a phonebook field to all Profiles pages. In order to allow to search for phonebook data the following line has to be changed in the 356c356 > $text = $fold($pn."\n".@$page['targets']."\n"..@$page['phonebook']."\n".@$page['text']); If you are using the PageListExtensions cookbook change the following line in this cookbook: 230c230 > $text = $pn."\n".@$page['targets']."\n".@$page['phonebook']."\n".@$page['text']; Now that the phonebook information can be searched a separate Profiles.Search? page can be created. First this file should suppress the GroupHeader. Also the result list of a phonebook needs a different layout: (:nogroupheader:) (:title Employee search:) (:searchbox group=Profiles list=normal fmt=#phonebook:) ---- (:searchresults:) For the layout of the phonebook search results add the following template to the Site.LocalTemplates page:
[[#phonebook]]
(:if equal {<$Group}:)
(:table class=phonebook width="90%" :)
(:cell style="background:#e5e5ff;padding-left:5px" :)'''Name'''
(:cell style="background:#e5e5ff;padding-left:5px" :)%thd%'''Telephone'''
(:cell style="background:#e5e5ff;padding-left:5px" :)%thd%'''Room''' (:if:)
(:cellnr style="background:#eeeeff;padding-left:5px" :)[[{=$FullName}|{=$Title}]]
(:cell style="background:#eeeeff;padding-left:5px" :){=$ldap_telephonenumber}
(:cell style="background:#eeeeff;padding-left:5px" :){=$ldap_physicaldeliveryofficename}
(:if equal {>$Group}:)
(:tableend:)(:if:)
[[#phonebookend]]
Finally finish the complete phonebook functionality by creating the home-page Profles.Profiles?. This page can present a search box like the Profiles.Search? screen, but for a somewhat smaller organization also the complete list of employees can be shown: (:nogroupheader:) (:title All employees:) (:pagelist group=Profiles list=normal:) Release NotesVersion 0.1This is my first attempt. Although the low number (I always start there) this first attempt now works quite well for some weeks now. This cookbook defines a new PageStore class in which the Because a refresh of all Profiles pages at every pagelist action would create too much overhead, this is only done once in a while. The interval is by default once per hour. Therefore a timestamp has to be kept (the file If the specification of the fields is changed, delete the Although I do not like altering the source of other scripts in order to make the recipe working, I did not find another way to let Pmwiki search for the phonebook information. Maybe the search fields can be made configurable in an upcoming version? Version 0.2Repaired a bug in the deletion of pages. A variable is used to configure pages to be kept and not deleted. Version 0.3The title of the pages is now refreshed as well. ContributorsComments
User notes?: If you use, used or reviewed this recipe, you can add your name. The following format is recognized:
* (+) Optional positive comment. Name, date * (-) Optional negative comment. Name, date These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |