http://sebastian.dietzold.de/blog/2004/11/01/wacko_ldap_hack
http://sebastian.dietzold.de/blog/2005/08/11/wacko_news_ldap_rss_atom_feed_and_bibtex
With this hack, your Wacko Wiki? gets an ACL Group Alias for every groupOfName Object. So you can reuse your LDAP Groups in your Wiki.
<?php
global $wakkaConfig;
show_array($wakkaConfig["aliases"]);
?>
Now you can create an admin page with the action {{ldapgroups}} to display all possible ACL Group aliases.
Good luck :-)
ldapgroups.php
<?php
################################################################################
# Code by Sebastian Dietzold (http://sebastian.dietzold.de)
# License: GPL
# Doku: http://sebastian.dietzold.de/blog/2004/11/01/wacko_ldap_hack
################################################################################
################################################################################
# CONFIG
################################################################################
$ldapCONFIG['host']="ldapserver.domain.tld";
$ldapCONFIG['port']="389";
#$ldapCONFIG['binddn']="";
#$ldapCONFIG['bindpass']="";
$ldapCONFIG['basedn']="ou=Groups,dc=domain,dc=tld";
################################################################################
# auth_anon
#
# anonymous bind to ldap-server and return of the ldap-link
#
################################################################################
function auth_anon ($ldapCONFIG) {
# Connecten
$ldapCONFIG['link'] = ldap_connect($ldapCONFIG['host'], $ldapCONFIG['port']);
if (!$ldapCONFIG['link'])
{
print("ldap_connect: failed");
return FALSE;
}
# anonymus bind
if (!ldap_bind($ldapCONFIG['link']))
{
print("ldap_bind: anonymous failed");
return FALSE;
};
return $ldapCONFIG;
}
################################################################################
# auth_named
#
################################################################################
function auth_named ($ldapCONFIG) {
# anonymous first
$ldapCONFIG = auth_anon($ldapCONFIG);
if ((!$ldapCONFIG)||(!$ldapCONFIG['link']))
{
print("auth_named: no ldap_link from auth_anon()");
return FALSE;
};
if (!ldap_bind($ldapCONFIG['link'], $ldapCONFIG['binddn'], $ldapCONFIG['bindpass']))
{
print("auth_named ldap_bind: failed");
return FALSE;
}
}
################################################################################
# show_array($array)
#
# This function will print all the keys of a multidimensional array in html
# tables. It will help to debug when you don´t have control of depths.
################################################################################
function show_array($array)
{
echo "<table width='100%' border='1' bordercolor='#6699CC' cellspacing='0' cellpadding='5'><tr valign='top'>";
foreach ($array as $key => $value )
{
echo "<td align='center' bgcolor='#EEEEEE'>
<table border='2' cellpadding='3'><tr><td bgcolor='#FFFFFF'>$key (<code style='white-space:pre;'>$value</code>)</td></tr></table>";
if (is_array($array[$key])) show_array ($array[$key]);
echo "</td>";
}
echo "</tr></table>";
}
################################################################################
# add_ldap_groups_to_array($array)
#
################################################################################
function add_ldap_groups_to_array($array)
{
global $ldapCONFIG;
error_reporting(0);
$ldapCONFIG = auth_anon($ldapCONFIG);
$ds = $ldapCONFIG['link'];
$sr=ldap_search($ds, $ldapCONFIG['basedn'], "cn=*");
ldap_sort( $ds, $sr, "cn" );
$info = ldap_get_entries($ds, $sr);
for ($i=0; $i<$info["count"]; $i++)
{
$cn = $info[$i]["cn"][0];
#echo recode("UTF-8..", $info[$i]["cn"][0]) ."<br />";
$aliasString = "Administrator";
for ($j=0; $j<$info[$i]["member"]['count']; $j++)
{
$dn = $info[$i]["member"][$j];
$dn = eregi_replace("^cn=", "", $dn);
$dn = eregi_replace(",.*", "", $dn);
$dn = eregi_replace(' 1$', "", $dn);
$dn = eregi_replace(" ", "", $dn);
$aliasString .= "\n" . $dn;
}
#echo $aliasString ."<br />";
$array[$cn] = $aliasString;
}
#show_array($wakkaConfig["aliases"]);
ldap_close($ds);
return $array;
}
#include("../wakka.config.php");
#show_array($wakkaConfig["aliases"]);
#$wakkaConfig["aliases"] = add_ldap_groups_to_array($wakkaConfig["aliases"]);
#show_array($wakkaConfig["aliases"]);
?>