[f0s@mail] /home/artpaint/www/data/mozilla.artpaint/moz/> cat mozilla.config
#!/usr/local/bin/perl
use CGI qw/:standard :cgi/;
use Net::LDAPS;
$user = $ENV{"REMOTE_USER"};
print header(
-type=>'application/x-javascript-config',
-expires=>'0'
);
$ldaphost="mail.artpaint";
$basedn="dc=artpaint,dc=spb,dc=ru";
$id=0;
$ldap=Net::LDAPS->new($ldaphost) or die $@;
$bind=$ldap->bind();
build_body($user,"uid");
if ($id>0)
{
$podval = <<"EOF";
lockPref("mail.accountmanager.accounts", "$accounts");
} catch(e) {
displayError("lockedPref", e);
}
EOF
print $podval;
};
$ldap->unbind;
sub build_body()
{
$userb=$_[0];
$attrb=$_[1];
$search=ldap_search($userb,"users",$attrb);
foreach $entry ($search->entries)
{
$mail=$entry->get_value('mail');
$mailhost='mail.artpaint';
$accstat=$entry->get_value('accountStatus');
$cn=$entry->get_value('displayName');
$o=$entry->get_value('o');
$uid=$entry->get_value('uid');
$gecos=$entry->get_value('gecos');
$mail_mod=$mail;
$mail_mod=~s/@/\%40/g;
if ($accstat eq "active")
{
$id=$id+1;
if ($id==1)
{
$header =<<"EOF";
try {
//displayError("$username");
lockPref("browser.bookmarks.added_static_root", true);
lockPref("browser.cache.disk.capacity", 10240);
lockPref("browser.download.dir", "H:");
lockPref("browser.download.save_converter_index", 0);
lockPref("browser.fixup.alternate.enabled", false);
lockPref("browser.link.open_external", 3);
lockPref("browser.link.open_newwindow", 3);
lockPref("browser.startup.homepage", "http://www.ya.ru/");
lockPref("browser.tabs.autoHide", false);
lockPref("browser.tabs.loadGroup", 1);
lockPref("browser.tabs.loadInBackground", true);
lockPref("browser.tabs.opentabfor.middleclick", true);
lockPref("browser.tabs.opentabfor.urlbar", false);
lockPref("browser.turbo.showDialog", false);
lockPref("general.smoothScroll", false);
lockPref("browser.enable_automatic_image_resizing", false);
lockPref("browser.chrome.site_icons", true);
lockPref("browser.chrome.toolbar_tips", true);
lockPref("browser.chrome.toolbar_style", 2);
lockPref("browser.history_expire_days", 5);
lockPref("browser.search.opensidebarsearchpanel", true);
lockPref("browser.search.opentabforcontextsearch", false);
lockPref("general.startup.chat", false);
lockPref("general.startup.editor", false);
lockPref("general.startup.addressbook", false);
lockPref("general.startup.browser", true);
lockPref("general.startup.mail", false);
lockPref("mail.accountmanager.defaultaccount", "account1");
lockPref("mail.smtp.defaultserver", "smtp1");
lockPref("mail.smtpserver.smtp1.auth_method", 1);
lockPref("mail.smtpserver.smtp1.hostname", "$mailhost");
lockPref("mail.smtpserver.smtp1.port", 465);
lockPref("mail.smtpserver.smtp1.try_ssl", 3);
lockPref("mail.smtpserver.smtp1.username", "$uid");
lockPref("mail.smtpservers", "smtp1");
lockPref("mail.spam.logging.enabled", false);
lockPref("mail.spam.manualMarkMode", 0);
lockPref("mail.spam.markAsReadOnSpam", true);
lockPref("mail.spam.manualMark", true);
lockPref("mail.spam.version", 1);
lockPref("ldap_2.autoComplete.directoryServer", "ldap_2.servers.artpaint");
lockPref("ldap_2.autoComplete.useDirectory", true);
lockPref("ldap_2.prefs_migrated", true);
lockPref("ldap_2.servers.artpaint.auth.savePassword", true);
lockPref("ldap_2.servers.artpaint.description", "mail.artpaint");
lockPref("ldap_2.servers.artpaint.filename", "abook-1.mab");
lockPref("ldap_2.servers.artpaint.maxHits", 500);
lockPref("ldap_2.servers.artpaint.position", 3);
lockPref("ldap_2.servers.artpaint.uri",
"ldaps://$ldaphost:636/ou=users,$basedn??sub");
lockPref("ldap_2.servers.history.filename", "history.mab");
lockPref("ldap_2.servers.history.replication.lastChangeNumber", 0);
lockPref("ldap_2.servers.pab.filename", "abook.mab");
lockPref("ldap_2.servers.pab.replication.lastChangeNumber", 0);
lockPref("network.cookie.prefsMigrated", true);
lockPref("network.proxy.ftp", "router.artpaint");
lockPref("network.proxy.ftp_port", 8787);
lockPref("network.proxy.gopher", "router.artpaint");
lockPref("network.proxy.gopher_port", 8787);
lockPref("network.proxy.http", "router.artpaint");
lockPref("network.proxy.http_port", 8787);
lockPref("network.proxy.no_proxies_on",
"localhost, 127.0.0.1, 192.168.10.0/24, *.artpaint");
lockPref("network.proxy.share_proxy_settings", true);
lockPref("network.proxy.ssl", "router.artpaint");
lockPref("network.proxy.ssl_port", 8787);
lockPref("network.proxy.type", 1);
lockPref("update_notifications.enabled", false);
lockPref("mail.toolbars.showbutton.print", true);
EOF
print $header;
};
$account="account".$id;
$zp="";
$zp="," if ($id>1);
$accounts="$accounts".$zp.$account;
$identi="id".$id;
$serv="server".$id;
$body_account =<<"EOF";
lockPref("mail.account.$account.identities", "$identi");
lockPref("mail.account.$account.server", "$serv");
lockPref("mail.forward_message_mode", 2);
lockPref("mail.identity.$identi.doBcc", false);
lockPref("mail.identity.$identi.doBccList", "");
lockPref("mail.identity.$identi.draft_folder",
"imap://$mail_mod\@$mailhost/Drafts");
lockPref("mail.identity.$identi.drafts_folder_picker_mode", "1");
lockPref("mail.identity.$identi.encryption_cert_name", "");
lockPref("mail.identity.$identi.encryptionpolicy", 0);
lockPref("mail.identity.$identi.fcc_folder",
"imap://$mail_mod\@$mailhost/Sent");
lockPref("mail.identity.$identi.fcc_folder_picker_mode", "1");
lockPref("mail.identity.$identi.fullName", "$cn");
lockPref("mail.identity.$identi.organization","ARTPAINT" );
lockPref("mail.identity.$identi.reply_to", "$mail");
lockPref("mail.identity.$identi.sign_mail", false);
lockPref("mail.identity.$identi.signing_cert_name", "");
lockPref("mail.identity.$identi.smtpServer", "smtp1");
lockPref("mail.identity.$identi.stationery_folder",
"imap://$mail_mod\@$mailhost/Templates");
lockPref("mail.identity.$identi.tmpl_folder_picker_mode", "1");
lockPref("mail.identity.$identi.useremail", "$mail");
lockPref("mail.identity.$identi.valid", true);
lockPref("mail.server.$serv.ageLimit", 30);
lockPref("mail.server.$serv.capability", 418609);
lockPref("mail.server.$serv.daysToKeepBodies", 30);
lockPref("mail.server.$serv.daysToKeepHdrs", 30);
lockPref("mail.server.$serv.download_on_biff", true);
lockPref("mail.server.$serv.check_new_mail", true);
lockPref("mail.server.$serv.check_time", 10);
lockPref("mail.server.$serv.cleanup_inbox_on_exit", true);
lockPref("mail.server.$serv.empty_trash_on_exit", true);
lockPref("mail.server.$serv.moveOnSpam", true);
lockPref("mail.server.$serv.hostname", "$mailhost");
lockPref("mail.server.$serv.login_at_startup", true);
lockPref("mail.server.$serv.max_cached_connections", 5);
lockPref("mail.server.$serv.name", "$gecos");
lockPref("mail.server.$serv.numHdrsToKeep", 30);
lockPref("mail.server.$serv.port", 10993);
lockPref("mail.server.$serv.socketType", 3);
lockPref("mail.server.$serv.realhostname", "$mailhost");
lockPref("mail.server.$serv.realuserName", "$mail");
lockPref("mail.server.$serv.type", "imap");
lockPref("mail.server.$serv.useSecAuth", false);
lockPref("mail.server.$serv.userName", "$mail");
lockPref("mail.server.$serv.spamActionTargetAccount",
"imap://$mail_mod\@$mailhost");
lockPref("mail.server.$serv.spamActionTargetFolder",
"imap://$mail_mod\@$mailhost/Junk");
EOF
print $body_account;
$searchg=ldap_search($userb,"Group","memberUid");
foreach $entryg ($searchg->entries)
{
$cng=$entryg->get_value('cn');
build_body($cng,"cn");
};
};
};
};
sub ldap_search ()
{
$attr=$_[2];
$val=$_[0];
$ou=$_[1];
$filter="($attr=$val)";
$searchs=$ldap->search(
scope =>'sub',
base =>"ou=$ou,".$basedn,
filter =>$filter,
attrs =>['mail','mailHost','accountStatus',
'displayName','o','uid','gecos']
);
return $searchs
};
[f0s@mail] /home/artpaint/www/data/mozilla.artpaint/moz/>
|