[Pmwiki-users] Re: PmWiki development

J. Perkins jason
Mon Jun 14 15:43:07 CDT 2004


Bob Dively wrote:
> be punished and the innocent completely ignored. I'd love to see some sort
> of user authentication scheme that allowed me to hack up a Cookbook
> extension to query a corporate LDAP server.

I'm using PmWiki in a corporate environment where everyone runs IE5 and 
authenticates against Active Directory. I made the following 
modifications to get automatic user detection in PmWiki.

1) In your pmwiki/pub directory create a directory named "auth" 
containing a file named "authenticate.php" with the contents:

   <?php
   session_start();
   $id = $_SERVER['LOGON_USER'];
   $_SESSION['LOGON_USER'] = substr(strrchr($id,'\\'),1);
   header('Location: '.$_SESSION['IISAuthReturn']);
   ?>

2) Go into the "Internet Services Administration" and turn off 
"Anonymous Access for the new directory. Now everyone's logon IDs will 
be sent to the server when they access the site.

3) In your pmwiki/local directory, create a file called 'iisauth.php' 
with the contents:

   <?php
   $AuthFunction = 'IISAuth';
   SDV($IISAuthUrl, "$PubDirUrl/auth");

   function IISAuth($pagename,$level,$authprompt=true)
   {
     global $Author, $ScriptUrl;
     if ($level != 'read')
     {
       session_start();
       if ($_SESSION['LOGON_USER'])
         $Author = $_SESSION['LOGON_USER'];
       else {
         $_SESSION['IISAuthReturn'] = 
"$ScriptUrl?pagename=$pagename&action=$level";
         header("Location: $PubDirUrl/auth/authenticate.php");
         exit;
       }
     }
     $page = ReadPage($pagename);
     return $page;
   }

4) include_once('local/iisauth.php') in your config.php.

Now, the author field will be automatically filled in the with the users 
logon ID. I went the extra step and made the author field read-only so 
users couldn't change it. This doesn't actually do any authorization -- 
anyone can read and edit the site -- but it should be straightforward to 
add, depending on your requirements.

If someone could finish this up and package it as a cookbook scripts I 
would sure appreciate it, I keep meaning to but never find the time.

Jason






More information about the pmwiki-users mailing list