This commit is contained in:
SJ
2011-12-27 20:51:56 +01:00
parent da99ff359b
commit b06fae4031
14 changed files with 199 additions and 42 deletions

View File

@ -122,6 +122,7 @@ create table if not exists `counter` (
`rcvd` bigint unsigned default 0,
`virus` bigint unsigned default 0,
`duplicate` bigint unsigned default 0
`ignore` bigint unsigned default 0
) Engine=InnoDB;
insert into `counter` values(0, 0, 0);
@ -147,3 +148,51 @@ create table if not exists `user_settings` (
create index `user_settings_idx` on `user_settings`(`username`);
create table if not exists `user` (
`uid` int unsigned not null primary key,
`gid` int unsigned not null,
`username` char(64) not null unique,
`realname` char(64) default null,
`password` char(48) default null,
`domain` char(64) default null,
`dn` char(255) default '*',
`policy_group` int(4) default 0,
`isadmin` tinyint default 0
) Engine=InnoDB;
insert into `user` (`uid`, `gid`, `username`, `realname`, `password`, `policy_group`, `isadmin`, `domain`) values (0, 0, 'admin', 'built-in piler admin', '$1$PItc7d$zsUgON3JRrbdGS11t9JQW1', 0, 1, 'local');
create table if not exists `email` (
`uid` int unsigned not null,
`email` char(128) not null primary key
) ENGINE=InnoDB;
insert into `email` (`uid`, `email`) values(0, 'admin@local');
create table if not exists `email_groups` (
`uid` int unsigned not null,
`gid` int unsigned not null,
unique key `uid` (`uid`,`gid`),
key `email_groups_idx` (`uid`,`gid`)
) ENGINE=InnoDB;
create table if not exists `remote` (
`remotedomain` char(64) not null primary key,
`remotehost` char(64) not null,
`basedn` char(64) not null,
`binddn` char(64) not null,
`sitedescription` char(64) default null
) ENGINE=InnoDB;
create table if not exists `domain` (
`domain` char(64) not null primary key,
`mapped` char(64) not null
) ENGINE=InnoDB;
insert into `domain` (`domain`, `mapped`) values('local', 'local');

77
util/ldap_sync.php Normal file
View File

@ -0,0 +1,77 @@
<?php
$webuidir = "";
if(isset($_SERVER['argv'][1])) { $webuidir = $_SERVER['argv'][1]; }
require_once($webuidir . "/config.php");
require(DIR_SYSTEM . "/startup.php");
require(DIR_SYSTEM . "/ldap.php");
$trash_passwords = 0;
$cfg = read_konfig(LDAP_IMPORT_CONFIG_FILE);
foreach ($_SERVER['argv'] as $argv) {
if($argv == "--trash-passwords") {
$trash_passwords = 1;
}
}
$loader = new Loader();
$language = new Language();
Registry::set('language', $language);
if(MEMCACHED_ENABLED) {
$memcache = new Memcache();
foreach ($memcached_servers as $m){
$memcache->addServer($m[0], $m[1]);
}
Registry::set('memcache', $memcache);
}
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PREFIX);
Registry::set('db', $db);
$loader->model('user/user');
$loader->model('user/import');
$import = new ModelUserImport();
$_SESSION['username'] = 'cli-admin';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$totalusers = 0;
$totalnewusers = 0;
$totaldeletedusers = 0;
extract($language->data);
foreach ($cfg as $ldap_params) {
$users = $import->model_user_import->queryRemoteUsers($ldap_params, $ldap_params['domain']);
$rc = $import->model_user_import->fillRemoteTable($ldap_params, $ldap_params['domain']);
$totalusers += count($users);
list($newusers, $deletedusers) = $import->model_user_import->processUsers($users, $ldap_params);
list($a1, $a2) = $import->model_user_import->processUsers($users, $ldap_params);
$totalnewusers += $newusers;
$totaldeletedusers += $deletedusers;
if($trash_passwords == 1) {
$import->model_user_import->trashPassword($users);
}
}
$total_emails_in_database = $import->model_user_import->count_email_addresses();
print date(LOG_DATE_FORMAT); ?>, <?php print $totalusers; ?>/<?php print $totalnewusers; ?>/<?php print $totaldeletedusers; ?>/<?php print $total_emails_in_database; ?>