diff -urP retrieveuserdata.orig/config.php retrieveuserdata/config.php
--- retrieveuserdata.orig/config.php	Thu Oct 31 22:54:42 2002
+++ retrieveuserdata/config.php	Thu Oct 31 22:59:18 2002
@@ -10,6 +10,10 @@
          $SQRUD_MYSQL_DB, $SQRUD_MYSQL_TABLE, $SQRUD_MYSQL_NAME_FIELD,
          $SQRUD_MYSQL_MAIL_FIELD, $SQRUD_MYSQL_USERNAME_FIELD,
          $SQRUD_MYSQL_USE_PERSISTENT;
+  global $SQRUD_PGSQL_SERVER, $SQRUD_PGSQL_PORT, $SQRUD_PGSQL_USER,
+         $SQRUD_PGSQL_PASS, $SQRUD_PGSQL_DB, $SQRUD_PGSQL_TABLE,
+         $SQRUD_PGSQL_NAME_FIELD, $SQRUD_PGSQL_MAIL_FIELD,
+         $SQRUD_PGSQL_USERNAME_FIELD, $SQRUD_PGSQL_USE_PERSISTENT;
 
   /*
    *  $SQRUD_RETRIEVE_DATA_FROM - file containing retrieve_data() function,
@@ -19,6 +23,7 @@
    */
   $SQRUD_RETRIEVE_DATA_FROM = "ldap.php";
 //  $SQRUD_RETRIEVE_DATA_FROM = "mysql.php";
+//  $SQRUD_RETRIEVE_DATA_FROM = "pgsql.php";
 //  $SQRUD_RETRIEVE_DATA_FROM = "passwd.php";
 
   $SQRUD_RETRIEVE_ON_EVERY_LOGIN = 1;
@@ -71,5 +76,36 @@
  *  $SQRUD_MYSQL_USE_PERSISTENT = 1;
  *
  */
-   
+
+
+   /*
+    *  PostgreSQL Configuration, if you use pgsql.php in $SQRUD_RETRIEVE_DATA_FROM
+    *
+    *  $SQRUD_PGSQL_SERVER - your PostgreSQL server
+    *  $SQRUD_PGSQL_PORT - TCP/IP port the PostgreSQL server is listening on
+    *  $SQRUD_PGSQL_USER - PostgreSQL server username
+    *  $SQRUD_PGSQL_PASS - PostgreSQL server password
+    *  $SQRUD_PGSQL_DB - PostgreSQL database
+    *  $SQRUD_PGSQL_TABLE - The table to lookup the values in
+    *  $SQRUD_PGSQL_NAME_FIELD - The field containing the full name
+    *  $SQRUD_PGSQL_MAIL_FIELD - The field containing the emailadress
+    *  $SQRUD_PGSQL_USERNAME_FIELD - The field to match
+    *  $SQRUD_PGSQL_USE_PERSISTENT - Whether or not to use persistent database
+    *                                connections.
+    *
+    */
+   /*
+ *  $SQRUD_PGSQL_SERVER = 'sql.server.net';
+ *  $SQRUD_PGSQL_PORT = 5432;
+ *  $SQRUD_PGSQL_USER = 'username';
+ *  $SQRUD_PGSQL_PASS = 'p@ssword';
+ *  $SQRUD_PGSQL_DB = 'database';
+ *  $SQRUD_PGSQL_TABLE = 'table';
+ *  $SQRUD_PGSQL_NAME_FIELD = 'fullname';
+ *  $SQRUD_PGSQL_MAIL_FIELD = 'email';
+ *  $SQRUD_PGSQL_USERNAME_FIELD = 'id';
+ *  $SQRUD_PGSQL_USE_PERSISTENT = 1;
+ *
+ */
+
 ?>
diff -urP retrieveuserdata.orig/pgsql.php retrieveuserdata/pgsql.php
--- retrieveuserdata.orig/pgsql.php	Thu Jan  1 01:00:00 1970
+++ retrieveuserdata/pgsql.php	Thu Oct 31 22:55:12 2002
@@ -0,0 +1,64 @@
+<?php
+   /*
+    *   pgsql.php
+    *
+    *   PostgreSQL server access
+    *   SquirrelMail Retrieve User Data Plugin
+    *   By Ralf Kraudelt <kraude@wiwi.uni-rostock.de>
+    *   PostgreSQL support by Mark Bergsma <mark@nedworks.org>
+    *
+    *   pgsql.php uses some configuration values from config.php
+    */
+
+function retrieve_data ($uid, $passwd) {
+    global  $SQRUD_PGSQL_SERVER, $SQRUD_PGSQL_PORT, $SQRUD_PGSQL_USER,
+            $SQRUD_PGSQL_PASS, $SQRUD_PGSQL_DB, $SQRUD_PGSQL_TABLE,
+            $SQRUD_PGSQL_NAME_FIELD, $SQRUD_PGSQL_MAIL_FIELD,
+            $SQRUD_PGSQL_USERNAME_FIELD, $SQRUD_PGSQL_USE_PERSISTENT;
+
+    $pgsql_error = 0;
+    $common_name = '';
+    $mail_address = '';
+
+    /* Build a pgsql connection string */
+    $conn_str = " host=".$SQRUD_PGSQL_SERVER.
+                " port=".$SQRUD_PGSQL_PORT.
+                " user=".$SQRUD_PGSQL_USER.
+                " password=".$SQRUD_PGSQL_PASS.
+                " dbname=".$SQRUD_PGSQL_DB;
+
+    /* Open a connection to PostgreSQL */
+    if (SQRUD_PGSQL_USE_PERSISTENT)
+        $pgsql = pg_pconnect($conn_str) or $pgsql_error = 1;
+    else
+        $pgsql = pg_connect($conn_str) or $pgsql_error = 1;
+
+    /* Query the database */
+    if ($pgsql_error == 0) {
+        $uid = addslashes($uid);
+        $query =   "SELECT $SQRUD_PGSQL_NAME_FIELD, $SQRUD_PGSQL_MAIL_FIELD
+                    FROM $SQRUD_PGSQL_TABLE
+                    WHERE $SQRUD_PGSQL_USERNAME_FIELD = '$uid'";
+        
+	$search_result = pg_exec($pgsql, $query) or $pgsql_error = 1;
+    }
+
+    /* Parse the results */
+    if ($pgsql_error == 0) {
+        if ($info = pg_fetch_array($search_result)) {
+            $common_name = $info[$SQRUD_PGSQL_NAME_FIELD];
+            $mail_address = $info[$SQRUD_PGSQL_MAIL_FIELD];
+        }
+        else
+            $pgsql_error = 1;
+    }
+    
+    /* Close the connection if needed */
+    if (! $SQRUD_PGSQL_USE_PERSISTENT)
+        pg_close($pgsql);
+
+    /* Return the results */
+    return array("error"=>$pgsql_error, "common_name"=>$common_name, "mail_address"=>$mail_address);
+}
+
+?>
