Go to the source code of this file.
|
| $config = "/var/alternc/bureau/class/local.php" |
| Le but de ce script est deux choses: More...
|
|
| $bar = @include($config) |
|
if(function_exists("ldap_connect")) | else |
|
◆ graceful_failure()
if ( $bar===FALSE) graceful_failure |
( |
| ) |
|
sortir sans erreur et avec des instructions pour l'usager
Definition at line 35 of file 0.9.2.php.
37 echo
"assuming accounts have already been transfered\n";
38 echo
"if that is not the case:\n";
39 echo
" - make sure the LDAP server is running\n";
40 echo
" - make sure the login information is correct (in $config)\n";
41 echo
" - restart this script (".$_SERVER[
'argv'][0].
")\n";
46 echo
"Step 1: converting the LDAP database to MySQL, hold on\n";
47 echo
" a dot (.) is printed for each 10 successful request\n";
48 echo
" a X is printed for each failed request.\n";
49 echo
" Usually, those failed requests occur when an entry is already present\n";
50 echo
" in the database and can generally be ignored\n";
56 if (function_exists(
"ldap_connect")) {
57 if (!($ds=ldap_connect($L_LDAP_HOST))) {
58 echo
"cannot connect to ldap server \"$L_LDAP_HOST\"\n";
62 if (!(ldap_bind($ds,$L_LDAP_ROOT,$L_LDAP_ROOTPWD))) {
64 echo
"cannot bind to ldap server \"$L_LDAP_HOST\" with user \"$L_LDAP_ROOT\"\n";
71 echo
"cannot connect to mysql server\n";
75 echo
"cannot connect to mysql database\n";
80 $sr=ldap_search($ds,
"dc=domains,".$L_LDAP_POSTFIX,
"(objectclass=mail)",
81 array(
"mail",
"uid",
"account",
"pop",
"type"));
83 if (
$info[
"count"]==0) {
84 echo
"INFO : Aucun mail dans la base DOMAINS \n";
87 echo
"Transferring ".$info[
"count"].
" Entries from domains ";
89 if (
$info[
$i][
"type"][0]==
"mail") $type=0;
else $type=1;
91 if (count(
$info[
$i][
"account"]) > 1) {
92 unset(
$info[
$i][
"account"][
'count']);
93 $accounts = join(
"\n",
$info[
$i][
"account"]);
95 mysql_query(
"INSERT INTO mail_domain (mail,alias,uid,pop,type) VALUES ('".
96 addslashes(
$info[
$i][
"mail"][0]).
"','".
97 addslashes($accounts).
"','".
98 addslashes(
$info[
$i][
"uid"][0]).
"','".
99 addslashes(
$info[
$i][
"pop"][0]).
"','$type');") ||
print "X";
100 if ((
$i/10.0)==intval(
$i/10)) { echo
"."; flush(); }
104 $sr=ldap_search($ds,
"dc=aliases,".$L_LDAP_POSTFIX,
"(objectClass=alias)",
105 array(
"mail",
"alias"));
107 if (
$info[
"count"]==0) {
108 echo
"INFO : Aucun mail dans la base ALIASES \n";
111 echo
"Transferring ".$info[
"count"].
" Entries from aliases ";
113 mysql_query(
"INSERT INTO mail_alias (mail,alias) VALUES ('".
114 addslashes(
$info[
$i][
"mail"][0]).
"','".
116 if ((
$i/10.0)==intval(
$i/10)) { echo
"."; flush(); }
121 $sr=ldap_search($ds,
"dc=users,".$L_LDAP_POSTFIX,
"(objectClass=posixAccount)",
122 array(
"uid",
"gidNumber",
"homeDirectory",
"userPassword"));
124 if (
$info[
"count"]==0) {
125 echo
"INFO : Aucun mail dans la base USERS \n";
129 echo
"Transferring ".$info[
"count"].
" Entries from users ";
132 $pass=substr(
$info[
$i][
"userpassword"][0],7);
133 mysql_query(
"INSERT INTO mail_users (uid,alias,path,password) VALUES ('".
134 addslashes(
$info[
$i][
"gidnumber"][0]).
"','".
135 addslashes(
$info[
$i][
"uid"][0]).
"','".
136 addslashes(
$info[
$i][
"homedirectory"][0]).
"','".
137 addslashes($pass).
"');") ||
print "X";
138 if ((
$i/10.0)==intval(
$i/10)) { echo
"."; flush(); }
144 echo
"ldap module not loaded into php, skipping LDAP conversion\n";
147 echo
"Step 2: encrypting user passwords ";
149 if (!mysql_query(
"use $L_MYSQL_DATABASE")) {
150 echo
"can't select database $L_MYSQL_DATABASE\n";
153 if (
$q = mysql_query(
"SELECT LENGTH(`pass`) AS len FROM `membres` GROUP BY len ORDER BY len ASC;")) {
154 if (
$res = mysql_fetch_array(
$q)) {
155 if (
$res[
'len'] == 34) {
156 print "(already encrypted)";
158 if (!(
$q = mysql_query(
"SELECT uid,pass FROM membres;"))) {
159 echo
"SELECT failed: " . mysql_error() .
"\n";
162 while (
$c = mysql_fetch_array(
$q)) {
166 if (!mysql_query(
"UPDATE membres SET pass='$pass' WHERE uid='$id';")) {
167 echo
"UPDATE failed: " . mysql_error() .
"\n";
174 echo
"fetch_array() failed: ". mysql_error().
"\n";
if(!($ds=ldap_connect($L_LDAP_HOST))) if(!(ldap_bind($ds, $L_LDAP_ROOT, $L_LDAP_ROOTPWD))) if(!mysql_connect($L_MYSQL_HOST, $L_MYSQL_LOGIN, $L_MYSQL_PWD)) if(!mysql_select_db($L_MYSQL_DATABASE)) $sr
$config
Le but de ce script est deux choses:
if($bar===FALSE) graceful_failure()
sortir sans erreur et avec des instructions pour l'usager
_md5cr($pass, $salt="")
Hashe a password using proper crypto function.
if(!isset($is_include)) if(! $key &&! $crt) $id
References $config, and exit.
◆ $bar
◆ $config
$config = "/var/alternc/bureau/class/local.php" |
Le but de ce script est deux choses:
- migration des données LDAP vers les bases MYSQL de mx/imap
- conversion des mots de passe en "crypt"
dépendances de ce script: php4-cgi + php4-ldap + php4-mysql pour la migration ldap=>mysql du mail donc le script "0.9.1_migrationldap.php" for _md5cr()
Definition at line 25 of file 0.9.2.php.
Referenced by graceful_failure(), and m_ssl\new_csr().
◆ else
if (!mysql_query("use $L_MYSQL_DATABASE")) if ( $q=mysql_query("SELECT LENGTH(`pass`) AS len FROM `membres` GROUP BY len ORDER BY len ASC;")) else |
Initial value:{
echo "ldap module not loaded into php, skipping LDAP conversion\n"
Definition at line 143 of file 0.9.2.php.