[imp] virtual hosting based on ldap info

Alexánder Murillo Herrera alexander at novasitios.com
Tue Jul 29 13:33:42 PDT 2003


Replace de function "imp_expand_fromaddress" in file imp/config/conf.php

And assign the function to $conf['hooks']['from']

Best regards,
Alexánder M.

-----Original Message-----
From: imp-bounces at lists.horde.org [mailto:imp-bounces at lists.horde.org]
On Behalf Of Caylan Van Larson
Sent: Tuesday, July 29, 2003 1:34 PM
To: imp at lists.horde.org
Subject: [imp] virtual hosting based on ldap info


Hi,

Here at school we have user at cs.und.edu and user at aero.und.edu accounts.  
The previous two addresses are identical and mail is accepted for both 
addresses and delivered to "user."

Most users dont care to understand this concept and think that their
email 
address is "wrong" when the domain is not as expected.  Thus, I have to 
come up with a way to have their from address (maildomain/realm) change 
based on some ldap information, easiest being their home directories 
because of how we split compsci and avit students.

Code placed in imp/config/servers.php will allow me to change 
maildomain/realm based on variables available *before* a user ever types

in their username.

Here is my code:
--SNIP
// Connect to the ldap server.
....

// Identifiers and vdomains.
$vdomains['Sirius'] = 'aero.und.edu';
$vdomains['Agassiz'] = 'cs.und.edu';

// Default vdomain
$vdomain = 'aero.und.edu';

if( $hack_ldap_resource )
{
    $hack_ldap_user = $_REQUEST['imapuser'];
    $hack_ldap_basedn = 'ou=people,dc=aero,dc=und,dc=edu';
    $hack_ldap_search = 'uid='.$hack_ldap_user;
    $hack_ldap_results = ldap_search($hack_ldap, $hack_ldap_basedn,
$hack_ldap_search);
    $hack_ldap_info = ldap_get_entries($hack_ldap, $hack_ldap_results);
    $hack_ldap_homedir = $hack_ldap_info[0]['homedirectory'][0];

    foreach( $vdomains as $vdomain_key => $vdomain_value )
    {
        //echo "Searching for $vdomain_key in $hack_ldap_homedir...";
        if( preg_match("/$vdomain_key/", $hack_ldap_homedir) )
        {
            //echo "FOUND!<br>";
            $vdomain = $vdomains[$vdomain_key];
            //echo "Vdomain set to $vdomain<br>";
            break;
        }
        //echo "<br>";
    }
}
--SNAP

So here are two questions:

1) Where can I put this code so I can effectively change
maildomain/realm 
while still being able to access the username provided at the initial
form?

2) Instead, is there a configuration that will only allow usernames in
the 
form "username at example.com" then set the maildomain/realm according to
the 
address provided?  (And only allow a certain set of domains?)

The trouble with #2 is students will have access to both type of
accounts 
because horde/imp stores them under different accounts thus different 
preferences for the same email address.

Thanks,



Caylan Van Larson
Unix Administrator - Systems Team Member
University of North Dakota (Aerospace College) caylan at cs.und.edu
701-777-6151 (work)


-- 
IMP mailing list
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: imp-unsubscribe at lists.horde.org

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.488 / Virus Database: 287 - Release Date: 6/5/2003
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.488 / Virus Database: 287 - Release Date: 6/5/2003
 



More information about the imp mailing list