Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to autoconfig with LDAP from Active Directory?

944 views
Skip to first unread message

konus

unread,
Jan 18, 2012, 4:11:36 AM1/18/12
to tb-ent...@mozilla.org
Hello,
I have some Win7-64bit clients and would like to use auto-configuration with LDAP like described here:
https://developer.mozilla.org/en/MCD,_Mission_Control_Desktop_AKA_AutoConfig

As LDAP-source I would like to use an Active Directory (Windows Server 2008 R2). I gave anonymous read access to Active Directory and changed the script in the following way, but it does not work:

-------------snip thunderbird.cfg------------------
...
/* 3) define here (because if set after "4)" below it doesn't work !) processLDAPValues which is eventually called by getLDAPAttributes() just below,
check getLDAPAttributes() code from $MOZILLA_HOME/defaults/autoconfig/prefcalls.js to see the inside call to "user defined" processLDAPValues
*/
function processLDAPValues (values) {
if(values) {
// set the global var with the values returned from the LDAP query
ldap_values = values;
var sAMAccountName = getLDAPValue(values ,"sAMAccountName");
var cn = getLDAPValue(values ,"cn");
var mail = getLDAPValue(values ,"mail");

// Those ldap variables are only available is this processLDAPValues context !
// so we set the preferences that need them here .
defaultPref("mail.identity.id1.useremail", mail);
defaultPref("mail.server.server1.name", mail );
defaultPref("mail.identity.id1.fullName", cn );
}
}
// 4) Call Ldap servers to get Ldap Attributes (mail & cn) , this will finally call processLDAPValues , "3)" just above.
// getLDAPAttributes("ldap.url","ou=people,o=Comapny","uid=" + env_user,"uid,cn,mail,labeledURI");
getLDAPAttributes("192.168.1.200","dc=domain,dc=local","sAMAccountName=" + env_user,"sAMAccountName,cn,mail");
...
-------------snap------------------

Unfortunately I have no luck with this. So I am looking for ideas how to debug. Is there anybody out there who already did autoconfig with an LDAP query to Active Directory?

Greetings Konus

konus

unread,
Jan 19, 2012, 10:58:27 AM1/19/12
to tb-ent...@mozilla.org
Solved:
----------------------autoconfig.cfg--------------------------
//Note: for accessing the Active Directory of Windows Server later than 2000
//it is necessary to allow anonymous read access. Please see
//(German) http://interop.blog.de/2010/02/13/kapitel-1-ldap-anfragen-linux-ad-8001564/
//or search the net how to do it. If it is not possible to give access to anonymous,
//you have to enable this function first, please see
//http://technet.microsoft.com/de-de/library/cc816788(WS.10).aspx
//
//
//put everything in a try/catch
try {

var userInfo = new Object(); // This will hold LDAP results

userInfo.envUser = getenv("USERNAME"); // USERNAME
userInfo.envHome = getenv("HOME"); // User home directory

var ldapHost = "example.com";
var ldapBase = "dc=company,dc=local";

if( userInfo.envUser )
{ var ldapFilter = "sAMAccountName=" + userInfo.envUser; }
else
{ throw("Couldn't get UID from the environment"); }

// LDAP attributes to retrieve from the server
var ldapAttrs = new Array( "cn", "mail", "sAMAccountName" ); // add more attributes here, if needed)

// Define how to process LDAP results before we make the call
function processLDAPValues(queryResults)
{ if( queryResults )
{ // Build the userInfo object for later use
for( var attr in ldapAttrs )
{ userInfo[ ldapAttrs[attr] ] = getLDAPValue( queryResults, ldapAttrs[attr] ); }
} else
{ throw( "No LDAP results" ); }
}

// Call upon LDAP for the values in ldapAttrs array,
// Uses the previous processLDAPValues()
getLDAPAttributes( ldapHost, ldapBase, ldapFilter, ldapAttrs.join(",") );

// create account
// see also http://blog.deanandadie.net/2010/06/easy-thunderbird-account-management-using-mcd/
// Identity
defaultPref("mail.identity.id1.fullName", userInfo.cn );
defaultPref("mail.identity.id1.smtpServer", "smtp1" );
defaultPref("mail.identity.id1.useremail", userInfo.mail );

// IMAP server settings
defaultPref("mail.server.server1.hostname", "myImap.server.com" );
defaultPref("mail.server.server1.name", userInfo.mail );
defaultPref("mail.server.server1.port", 993 );
defaultPref("mail.server.server1.socketType", 3 );
defaultPref("mail.server.server1.type", "imap" );
defaultPref("mail.server.server1.userName", userInfo.mail );

// SMTP server settings
defaultPref("mail.smtpserver.smtp1.authMethod", 3 );
defaultPref("mail.smtpserver.smtp1.description", "my Company Name" );
defaultPref("mail.smtpserver.smtp1.hostname", "mySmtp.server.com" );
defaultPref("mail.smtpserver.smtp1.port", 465 );
defaultPref("mail.smtpserver.smtp1.try_ssl", 3 );
defaultPref("mail.smtpserver.smtp1.username", userInfo.mail );

// Glue it all together
defaultPref("mail.account.account1.identities", "id1" );
defaultPref("mail.account.account1.server", "server1" );
defaultPref("mail.accountmanager.accounts", "account1" );
defaultPref("mail.accountmanager.defaultaccount", "account1" );
defaultPref("mail.smtp.defaultserver", "smtp1" );
defaultPref("mail.smtpservers", "smtp1" );

// Close the try, and call the catch()
} catch(e) {
displayError("lockedPref", e);
}
---------------end-------------------------------------
0 new messages