aboutsummaryrefslogtreecommitdiffstats
path: root/mayor-orig/www/include/backend/ads
diff options
context:
space:
mode:
Diffstat (limited to 'mayor-orig/www/include/backend/ads')
-rw-r--r--mayor-orig/www/include/backend/ads/auth/login.php358
-rw-r--r--mayor-orig/www/include/backend/ads/base/attrs.php160
-rw-r--r--mayor-orig/www/include/backend/ads/password/changePassword.php165
-rw-r--r--mayor-orig/www/include/backend/ads/session/accountInfo.php416
-rw-r--r--mayor-orig/www/include/backend/ads/session/base.php188
-rw-r--r--mayor-orig/www/include/backend/ads/session/createAccount.php157
-rw-r--r--mayor-orig/www/include/backend/ads/session/createGroup.php82
-rw-r--r--mayor-orig/www/include/backend/ads/session/search/searchAccount.php277
8 files changed, 0 insertions, 1803 deletions
diff --git a/mayor-orig/www/include/backend/ads/auth/login.php b/mayor-orig/www/include/backend/ads/auth/login.php
deleted file mode 100644
index 59cbf3e5..00000000
--- a/mayor-orig/www/include/backend/ads/auth/login.php
+++ /dev/null
@@ -1,358 +0,0 @@
-<?php
-/*
- Auth-ADS
-
- A név-jelszó pár ellenőrzése Active Directory adatbázis alapján
-*/
-
-/* --------------------------------------------------------------
-
- Felhasználók azonosítása az AD-ban tárolt person (konfigurálható)
- osztályok alapján történik.
-
- A függvény az előre definiált _AUTH_SUCCESS, _AUTH_EXPIRED, _AUTH_FAILURE
- konstansok valamelyikével tér vissza. (include/modules/auth/base/config.php)
-
- Sikeres hitelesítés esetén
- az egyéb account információkat (minimálisan a 'cn', azaz 'common name'
- attribútumot) a cím szerint átadott $accountInformation tömbbe helyezi el.
-
- Sikertelen azonosítás esetén a globális $_SESSION['alert'] változóban jelzi az
- elutasítás okát.
-
--------------------------------------------------------------- */
-
-######################################################################
-# Az LDAP protocol version 3 kötelező,
-# referals=0 nélkül használhatatlanul lassú
-######################################################################
-
- ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, 3);
- ldap_set_option(NULL, LDAP_OPT_REFERRALS, 0);
-
- /**
- * A userAccountControl pár fontos flag-e:
- *
- * Forrás: http://msdn.microsoft.com/en-us/library/windows/desktop/ms680832%28v=vs.85%29.aspx
- *
- * 512 Enabled Account
- * 514 Disabled Account
- * 544 Enabled, Password Not Required
- * 546 Disabled, Password Not Required
- * 66048 Enabled, Password Doesn't Expire
- * 66050 Disabled, Password Doesn't Expire
- * 66080 Enabled, Password Doesn't Expire & Not Required
- * 66082 Disabled, Password Doesn't Expire & Not Required
- * 590336 Enabled, User Cannot Change Password, Password Never Expires
- *
- * Ha pwdLastSet=0 és UF_DONT_EXPIRE_PASSWD=0, akkor következő bejelentkezéskor jelszót _kell_ változtatni.
- **/
- define('ADS_UF_ACCOUNTDISABLE',0x00000002); // The user account is disabled.
- define('ADS_UF_PASSWD_NOTREQD',0x00000020); // No password is required.
- define('ADS_UF_PASSWD_CANT_CHANGE',0x00000040); // The user cannot change the password.
- define('ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED',0x00000080); // The user can send an encrypted password.
- define('ADS_UF_NORMAL_ACCOUNT',0x00000200); // This is a default account type that represents a typical user.
- define('ADS_UF_DONT_EXPIRE_PASSWD',0x00010000); // The password for this account will never expire.
- define('ADS_UF_PASSWORD_EXPIRED',0x00800000); // The user password has expired.
-
- /**
- * Ha az accountExpires = 0 or 0x7FFFFFFFFFFFFFFF (9223372036854775807), akkor az account sose jár le. (nem a jelszó! az account.)
- **/
- define('ADS_ACCOUNTEXPIRES_NEVER','9223372036854775807');
-
- /**
- * Forrás: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724284%28v=VS.85%29.aspx
- * - unixDays - Az eltelt napok száma 1970-01-01-től
- * - unixTimestamp - Az eltelt másodpercek száma 1970-01-01 00:00:00-től
- * - msFileTime - A 1601-01-01 00:00:00-tól elteltt 100 nanosecundum-os intervallumok száma (1/10000000 sec)
- **/
- function msFileTime2unixDays($pwdLastSet) {
- return floor((($pwdLastSet / 10000000) - 11644406783) / 86400);
- }
- function msFileTime2unixTimestamp($pwdLastSet) {
- return bcsub(bcdiv($pwdLastSet, '10000000'), '11644473600');
- }
-
- function getAccountStatus($userAccount, $toPolicy, $userinfo, $ds) {
-
- /**
- * Meghatározza a felhasználói jelszó lejárati dátumát és az account egyéb fontos jellemzőit
- *
- * @params: $userAccount - a lekérdezendő account
- * @params: $userinfo - A user adatait tartalmazó korábbi LDAP lekérdezés eredménye (useraccountcontrol, pwdlastchange)
- * @params: $ds - LDAP csatlakozás azonosító
- * @requires: bcmath http://www.php.net/manual/en/book.bc.php
- * MSDN: http://msdn.microsoft.com/en-us/library/ms974598.aspx - a pwdLastSet 64 bites integer
- * @return: array
- * @param book $isGUID Is the username passed a GUID or a samAccountName
- **/
- global $AUTH;
-
- if ($toPolicy == '') $toPolicy = _POLICY;
- if (!function_exists('bcmod')) {
- $_SESSION['alert'][] = 'message:system_error:Nem támogatott függvényhívás [bcmod]! http://www.php.net/manual/en/book.bc.php';
- return false;
- };
-
- if (!$ds) {
- $closeLDAP = true;
- // Csatlakozzunk az LDAP kiszolgálóhoz!
- // Kapcsolódás a szerverhez
- $ds = ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- $_SESSION['alert'][] = 'alert:ldap_connect_failure';
- return false;
- }
-
- // Csatlakozás a szerverhez
- $r = @ldap_bind($ds,$AUTH[$toPolicy]['adsUser'],$AUTH[$toPolicy]['adsPw']);
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_bind_failure';
- return false;
- }
- }
-
- if (!is_array($userinfo)) {
- // Kérdezzük le az account adatait!
- $filter="(&(sAMAccountName=$userAccount)(objectClass=".$AUTH[$toPolicy]['adsUserObjectClass']."))";
- $justthese = array("sn","cn",$AUTH[$toPolicy]['adsStudyIdAttr'],"shadowexpire","shadowwarning","shadowinactive","shadowlastchange","shadowmax","pwdlastset","accountexpires","useraccountcontrol");
- $sr = ldap_search($ds, $AUTH[$toPolicy]['adsBaseDn'], $filter, $justthese);
- if (!$sr) {
- $_SESSION['alert'][] = "message:ldap_search_failure";
- if ($closeLDAP) ldap_close($ds);
- return false;
- }
- $userinfo = ldap_get_entries($ds,$sr);
- if ( $userinfo['count'] === 0 || is_null($userinfo)) { // http://bugs.php.net/50185 ha nincs megfelelő elem, akkor - hibásan - null-al tér vissza! (~ PHP 5.2.10)
- // Nincs ilyen userAccount (uid)
- $_SESSION['alert'][] = "message:no_account:$userAccount";
- if ($closeLDAP) ldap_close($ds);
- return false;
- }
- if ( $userinfo['count'] > 1 ) {
- // Több ilyen uid is van
- $_SESSION['alert'][] = "message:multi_uid";
- if ($closeLDAP) ldap_close($ds);
- return false;
- }
- }
- $pwdlastset = $userinfo[0]['pwdlastset'][0];
- $userAccountControl = $userinfo[0]['useraccountcontrol'][0];
-
- $status = array();
-
- $status['pwdLastSet'] = $pwdlastset;
- $status['pwdLastSetDt'] = date('Y-m-d H:i:s',msFileTime2unixTimestamp($pwdlastset));
- $status['accountExpires'] = $userinfo[0]['accountexpires'][0];
- $status['accountNeverExpires'] = (ADS_ACCOUNTEXPIRES_NEVER==$userinfo[0]['accountexpires'][0]) || ($userinfo[0]['accountexpires'][0] == 0);
- if (!$status['accountNeverExpires']) {
- $status['accountExpiresDt'] = date('Y-m-d H:i:s',msFileTime2unixTimestamp($userinfo[0]['accountexpires'][0]));
- $status['accountExpiresTimestamp'] = msFileTime2unixTimestamp($userinfo[0]['accountexpires'][0]);
- }
- $status['accountDisabled'] = (bool)($userAccountControl & ADS_UF_ACCOUNTDISABLE);
- $status['noPasswordRequired'] = (bool)($userAccountControl & ADS_UF_PASSWD_NOTREQD);
- $status['cannotChangePassword'] = (bool)($userAccountControl & ADS_UF_PASSWD_CANT_CHANGE);
- $status['normalAccount'] = (bool)($userAccountControl & ADS_UF_NORMAL_ACCOUNT);
- $status['passwordNeverExpire'] = (bool)($userAccountControl & ADS_UF_DONT_EXPIRE_PASSWD);
- $status['passwordExpired'] = (bool)($userAccountControl & ADS_UF_PASSWORD_EXPIRED); // Ez mintha nem működne...
- $status['mustChangePassword'] = ($pwdlastset === '0' && $status['passwordNeverExpire']);
-
- // A jelszó lejárati dátum az AD-ben két értékből számítható ki:
- // - A felhasználó saját pwdLastSet atribútuma: ez tárolja a jelszó utolsó módosításának időpontját
- // - A tartomány maxPwdAge atribútuma: milyen hosszú ideig lehet érvényes a jelszó a tartományban
- //
- // A Microsoft persze saját kiindulási időpontot és lépési egységet használ az idő tárolására.
- // Ez a függvény konvertálja ezt az értéket Unix időbélyeggé
-
- // Kérdezzük le a tartomány maxPwdAge attribútumát!
- $sr = ldap_read($ds, $AUTH[$toPolicy]['adsBaseDn'], 'objectclass=domain', array('maxPwdAge'));
- if (!$sr) {
- $_SESSION['alert'][] = "message:ldap_search_failure:getAccountStatus (ads backend)";
- if ($closeLDAP) ldap_close($ds);
- return false;
- }
- $info = ldap_get_entries($ds, $sr);
- $maxpwdage = $info[0]['maxpwdage'][0];
-
- // Lásd MSDN: http://msdn.microsoft.com/en-us/library/ms974598.aspx
- //
- // pwdLastSet tartalmazza az 1601 (UTC) január 1 óta eltelt 100 nanoszekundumos időintervallumok számát
- // 64 bit-es integer típusú értékként
- //
- // Ettől az időponttól a Unix időszámítás kezdetéig eltelt másodpercek száma 11644473600.
- //
- // maxPwdAge szintén large integer, ami a jelszóváltoztatás és a jelszó lejárat közötti 100 nanoszekundumos időintervallumok számát tárolja
-
- $status['maxPwdAgeInDays'] = bcdiv(bcsub(0,$maxpwdage),'36000000000')/24;
-
- // Ezt az étéket át kell váltanunk másodpercekre, de ez egy negatív mennyiség!
- //
- // Ha a maxPwdAge alsó 32 bites része 0, akkor a jelszavak nem járnak le
- //
- // Sajnos ezek a számok túl nagyok a PHP integer típusához, ezért kell a BCMath függvényeit használnunk
-
- $status['passwordsDoNotExpireInDomain'] = (bcmod($maxpwdage, 4294967296) === '0');
-
- // Adjuk össze a pwdlastset és maxpwdage értékeket (pontosabban az utóbbi negatív értéket
- // vonjuk ki az előbbiből), így megkapjuk a jelszó lejáratának időpontját a Microsoft féle
- // egységekben.
- $pwdexpire = bcsub($pwdlastset, $maxpwdage);
-
- // Konvertáljuk az MS féle időt unix időre
- $status['expiryTimestamp'] = bcsub(bcdiv($pwdexpire, '10000000'), '11644473600');
- $status['expiryDate'] = date('Y-m-d H:i:s', bcsub(bcdiv($pwdexpire, '10000000'), '11644473600'));
-
- if ($closeLDAP) ldap_close($ds);
-
- $status['userAccount'] = $userAccount;
- $status['usetAccountControl'] = $userAccountControl;
- $status['shadowLastChange'] = $userinfo[0]['shadowlastchange'][0];
- $status['shadowWarning'] = $userinfo[0]['shadowwarning'][0];
- $status['shadowInactive'] = $userinfo[0]['shadowinactive'][0];
- return array_merge($status);
-
-
- }
-
- function adsUserAuthentication($userAccount, $userPassword, &$accountInformation, $toPolicy) {
-
- global $AUTH;
-
- if ($toPolicy == '') {
- if ($accountInformation['policy'] != '') $toPolicy = $accountInformation['policy'];
-// elseif ($_REQUEST['toPolicy'] != '') $toPolicy = $_REQUEST['toPolicy'];
- else $toPolicy = _POLICY;
- }
-
- // Kapcsolódás a szerverhez
- $ds = ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- $_SESSION['alert'][] = 'alert:ldap_connect_failure';
- return _AUTH_FAILURE;
- }
-
- // Csatlakozás a szerverhez
- $r = @ldap_bind($ds,$AUTH[$toPolicy]['adsUser'],$AUTH[$toPolicy]['adsPw']);
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_bind_failure';
- return _AUTH_FAILURE;
- }
-
- // Van-e adott azonosítójú felhasználó?
- $filter="(&(sAMAccountName=$userAccount)(objectClass=".$AUTH[$toPolicy]['adsUserObjectClass']."))";
- $justthese = array("sn","cn",$AUTH[$toPolicy]['adsStudyIdAttr'],"shadowexpire","shadowwarning","shadowinactive","shadowlastchange","shadowmax","pwdlastset","accountexpires","useraccountcontrol");
- $sr = ldap_search($ds, $AUTH[$toPolicy]['adsBaseDn'], $filter, $justthese);
- if (!$sr) {
- $_SESSION['alert'][] = "message:ldap_search_failure";
- ldap_close($ds);
- return _AUTH_FAILURE;
- }
- $info = ldap_get_entries($ds,$sr);
- if ( $info['count'] === 0 || is_null($info)) { // http://bugs.php.net/50185 ha nincs megfelelő elem, akkor - hibásan - null-al tér vissza! (~ PHP 5.2.10)
- // Nincs ilyen userAccount (uid)
- $_SESSION['alert'][] = "message:no_account:$userAccount";
- ldap_close($ds);
- return _AUTH_FAILURE_1;
- }
-
- if ( $info['count'] > 1 ) {
- // Több ilyen uid is van
- $_SESSION['alert'][] = "message:multi_uid";
- ldap_close($ds);
- return _AUTH_FAILURE_2;
- }
-
- if ($info['count']==1) { // Van - egy - ilyen felhasználó
-
- $status = getAccountStatus($userAccount, $toPolicy, $info, $ds);
- // Lejárt-e
- // A lejárat ideje a shadowExpire és shadowLastChange+shadowMax kötül a kisebbik
- // Esetünkben
- if ($info[0]['pwdlastset'][0] != '') { // A pwdLastSet és shadowLastChange közül a kisebbiket használjuk
- $info[0]['shadowlastchange'][0] = msFileTime2unixDays($info[0]['pwdlastset'][0]);
- }
-
- // A globális beállítással kikényszeríthető a nagyobb warning időszak
- $shadowWarning = ($status['shadowWarning']<$AUTH[$toPolicy]['shadowWarning']) ? $AUTH[$toPolicy]['shadowWarning'] : $status['shadowWarning'];
-
-
- $disabled = ( // Ha az jelszavak lejárhatnak a domain-ben és a user jellszava is lejárhat és le is járt...
- !$status['passwordNeverExpire']
- && !$status['passwordsDoNotExpireInDomain']
- && $status['expiryTimestamp'] < time()
- ) || ( // vagy az account lejárhat és le is járt
- !$status['accountNeverExpires']
- && $status['accountExpiresTimestamp']<time()
- ); // Akkor már nem lehet belépni/jelszót változtatni...
- $expired = ( // Ha a jelszavak lejárhatnak és a user jelszava is lejárhat, és shadowwarning-on belül le fog járni a jelszó
- !$status['passwordNeverExpire']
- && !$status['passwordsDoNotExpireInDomain']
- && $status['expiryTimestamp'] - ($shadowWarning*24*60*60) < time()
- ) || ( // Ha az account lejárhat és shadow warning-on belül le is fog járni az account
- !$status['accountNeverExpires']
- && $status['accountExpiresTimestamp'] - ($shadowWarning*24*60*60) < time()
- ); // ...
-
- /**
- * Más backend-ben csak $AUTH[$toPolicy]['onDisabled'] == 'refuse' esetén utasítanánk el, de itt nincs más lehetőség...
- **/
- if ($disabled) {
- $_SESSION['alert'][] = 'message:account_disabled';
- ldap_close($ds);
- return _AUTH_FAILURE_4;
- }
-
- $accountInformation['cn'] = $info[0]['cn'][0];
- $accountInformation['studyId'] = $info[0][ $AUTH[$toPolicy]['adsStudyIdAttr'] ][0];
- $accountInformation['dn'] = $info[0]['dn'];
- $accountInformation['account'] = $userAccount;
- // Jelszó ellenőrzés - lehet-e csatlakozni
- if (!@ldap_bind($ds, $accountInformation['dn'], $userPassword)) {
- $_SESSION['alert'][] = 'message:bad_pw';
- return _AUTH_FAILURE_3;
- }
-
- ldap_close($ds);
- if (!$expired || $AUTH[$toPolicy]['onExpired'] == 'none') {
- return _AUTH_SUCCESS;
- } else {
- $pwLejar = floor(($status['expiryTimestamp'] - time()) / 86400);
- $_SESSION['alert'][] = 'info:account_warning:'.$pwLejar;
- $_SESSION['alert'][] = 'info:warn_account_disable:'.$pwLejar; // más backend esetén csak onDisable=refuse esetén szoktuk...
- if ($AUTH[$toPolicy]['onExpired'] == 'warning') {
- return _AUTH_SUCCESS;
- } elseif ($AUTH[$toPolicy]['onExpired'] == 'force update') {
- return _AUTH_EXPIRED;
- } else {
- return _AUTH_FAILURE;
- }
- }
-
-/*
- // Lejárt-e az azonosító
- if ($AUTH[$toPolicy]['onExpired'] != 'none' && isset($expireTimestamp)) { // onExpired: none | warning | force update
- // Lejárt-e
- $pwLejar = $expireTimestamp - floor(time()/(60*60*24));
- if (0 < $pwLejar && $pwLejar < $info[0]['shadowwarning'][0]) {
- $_SESSION['alert'][] = 'info:account_warning:'.$pwLejar;
- return _AUTH_SUCCESS;
- } elseif ($pwLejar <= 0) {
- $_SESSION['alert'][] = 'info:account_expired:'.abs($pwLejar);
- if ($AUTH[$toPolicy]['onDisabled'] == 'refuse') $_SESSION['alert'][] = 'info:warn_account_disable:'.($info[0]['shadowinactive'][0]+$pwLejar);
- if ($AUTH[$toPolicy]['onExpired'] == 'warning') {
- return _AUTH_SUCCESS;
- } elseif ($AUTH[$toPolicy]['onExpired'] == 'force update') {
- return _AUTH_EXPIRED;
- } else {
- return _AUTH_FAILURE;
- }
- }
- } // onExpired
- // Ha idáig eljut, akkor minden rendben.
- return _AUTH_SUCCESS;
-*/
- } // count == 1
-
- }
-
-?>
diff --git a/mayor-orig/www/include/backend/ads/base/attrs.php b/mayor-orig/www/include/backend/ads/base/attrs.php
deleted file mode 100644
index e01aa00c..00000000
--- a/mayor-orig/www/include/backend/ads/base/attrs.php
+++ /dev/null
@@ -1,160 +0,0 @@
-<?php
-/*
- Module: useradmin
-*/
-
- if (file_exists('lang/'._LANG.'/backend/ads/attrs.php')) {
- require('lang/'._LANG.'/backend/ads/attrs.php');
- } elseif (file_exists('lang/'._DEFAULT_LANG.'/backend/ads/attrs.php')) {
- require('lang/'._DEFAULT_LANG.'/backend/ads/attrs.php');
- }
-
-######################################################
-# Alapértelmezett jogosultságok
-#
-# w - Írható/olvasható
-# r - olvasható
-# - - egyik sem
-#
-# Három karakter: admin, self, other jogai
-######################################################
-
- define('_DEFAULT_ADS_RIGHTS','wr-');
-
-######################################################
-# Az LDAP account attribútumok
-######################################################
-
- global $adsAccountAttrs;
- $adsAccountAttrs = array(
- 'cn',
- 'sn',
- 'serialnumber',
- 'givenname',
- 'displayname',
- 'name',
- 'padpwdcount',
- 'badpasswordtime',
- 'lastlogon',
- 'pwdlastset', // ~ shadowLastChane
- 'accountexpires', // != shadowExpired - henme mi? 1601.01.01-től (60*60*24*1000*1000*10)*napok száma
- 'samaccountname',
- 'userprincipalname',
- 'useraccountcontrol',
- 'objectcategory',
- 'uid',
- 'mssfu30name',
- 'uidnumber',
- 'gidnumber',
- 'unixhomedirectory',
- 'loginshell',
-
- 'shadowlastchange',
- 'shadowexpire',
- 'shadowwarning',
- 'shadowmin',
- 'shadowmax',
- 'shadowinactive',
-
-/*
- 'gecos',
- 'mail',
- 'telephonenumber',
- 'mobile',
- 'l',
- 'street',
- 'postaladdress',
- 'postalcode',
- 'homedirectory',
-*/
- );
-
- global $adsGroupAttrs;
- $adsGroupAttrs = array(
- 'cn',
- 'description',
- 'member',
- 'name',
- 'samaccountname',
- 'objectcategory',
- 'gidnumber', // ennek kellene lennie - mitől lesz?
-/* 'memberuid' */
- );
-
- global $accountAttrToADS; // Kis és nagybetű számít!!!
- $accountAttrToADS = array(
- 'userAccount' => 'sAMAccountName',
- 'userCn' => 'displayName',
- 'mail' => 'mail',
- 'studyId' => 'serialNumber', // Ez konfig-ban külön van állítva, az itteni érték irreleváns
- 'shadowLastChange' => 'shadowLastChange',
- 'shadowWarning' => 'shadowWarning',
- 'shadowMin' => 'shadowMin',
- 'shadowMax' => 'shadowMax',
- 'shadowExpire' => 'shadowExpire',
- 'shadowInactive' => 'shadowInactive',
- );
-
- global $groupAttrToADS;
- $groupAttrToADS = array(
- 'groupCn' => 'cn',
- 'groupDesc' => 'description',
- 'member' => 'member',
- );
-
- global $adsAccountAttrDef;
- $adsAccountAttrDef = array(
- 'dn' => array('desc' => _ADSDN, 'type' => 'text', 'rights' => 'rrr'),
- 'cn' => array('desc' => _ADSCN, 'type' => 'text', 'rights' => 'rrr'),
- 'sn' => array('desc' => _ADSSN, 'type' => 'text', 'rights' => 'wrr'),
- 'givenname' => array('desc' => _ADSGIVENNAME, 'type' => 'text'),
- 'serialnumber' => array('desc' => _ADSSERIALNUMBER, 'type' => 'int', 'rights' => 'wrr'),
- 'displayname' => array('desc' => _ADSCN, 'type' => 'text', 'rights' => 'wrr'),
- 'name' => array('desc' => _ADSNAME, 'type' => 'text', 'rights' => 'r--'),
- 'padpwdcount' => array('desc' => _ADSBADPWDCOUNT, 'type' => 'int', 'rights' => 'wrr'),
- 'badpasswordtime' => array('desc' => _ADSBADPASSWORDTIME, 'type' => 'int', 'rights' => 'r--'),
- 'lastlogon' => array('desc' => _ADSLASTLOGON, 'type' => 'int', 'rights' => 'r--'),
- 'pwdlastset' => array('desc' => _ADSPWDLASTSET, 'type' => 'int', 'rights' => 'r--'),
- 'accountexpires' => array('desc' => _ADSACCOUNTEXPIRES, 'type' => 'int', 'rights' => 'wrr'),
- 'samaccountname' => array('desc' => _ADSSAMACCOUNTNAME, 'type' => 'text', 'rights' => 'wrr'),
- 'useraccountcontrol' => array('desc' => _USERACCOUNTCONTROL, 'type' => 'text', 'rights' => 'wrr'),
- 'userprincipalname' => array('desc' => _ADSUSERPRINCIPALNAME, 'type' => 'text', 'rights' => 'wrr'),
- 'objectcategory' => array('desc' => _ADSOBJECTCATEGORY, 'type' => 'text', 'rights' => 'r--'),
- 'uid' => array('desc' => _ADSUID, 'type' => 'text', 'rights' => 'rrr'),
- 'uidnumber' => array('desc' => _ADSUIDNUMBER, 'type' => 'int', 'rights' => 'w--'),
- 'gidnumber' => array('desc' => _ADSGIDNUMBER, 'type' => 'int', 'rights' => 'w--'),
- 'mssfu30name' => array('desc' => _ADSUID, 'type' => 'text', 'rights' => 'r--'),
- 'unixhomedirectory' => array('desc' => _ADSUNIXHOMEDIRECTORY, 'type' => 'text', 'rights' => 'wrr'),
- 'loginshell' => array('desc' => _ADSLOGINSHELL, 'type' => 'text', 'rights' => 'wrr'),
- 'shadowlastchange' => array('desc' => _ADSSHADOWLASTCHANGE, 'type' => 'text', 'rights' => 'wrr'),
- 'shadowexpire' => array('desc' => _ADSSHADOWEXPIRE, 'type' => 'text', 'rights' => 'wrr'),
- 'shadowwarning' => array('desc' => _ADSSHADOWWARNING, 'type' => 'text', 'rights' => 'wrr'),
- 'shadowmin' => array('desc' => _ADSSHADOWMIN, 'type' => 'text', 'rights' => 'wrr'),
- 'shadowmax' => array('desc' => _ADSSHADOWMAX, 'type' => 'text', 'rights' => 'wrr'),
- 'shadowinactive' => array('desc' => _ADSSHADOWINACTICE, 'type' => 'text', 'rights' => 'wrr'),
-/*
- 'gecos' => array('desc' => _ADSGECOS, 'type' => 'text', 'rights' => 'w--'),
- 'mail' => array('desc' => _ADSMAIL, 'type' => 'text', 'rights' => 'wwr'),
- 'telephonenumber' => array('desc' => _ADSTELEPHONENUMBER, 'type' => 'text', 'rights' => 'ww-'),
- 'mobile' => array('desc' => _ADSMOBILE, 'type' => 'text', 'rights' => 'ww-'),
- 'l' => array('desc' => _ADSL, 'type' => 'text'),
- 'street' => array('desc' => _ADSSTREET, 'type' => 'text'),
- 'postaladdress' => array('desc' => _ADSPOSTALADDRESS, 'type' => 'text'),
- 'postalcode' => array('desc' => _ADSPOSTALCODE, 'type' => 'text'),
-*/
- );
-
- global $adsGroupAttrDef;
- $adsGroupAttrDef = array(
- 'cn' => array('desc' => _ADSCN, 'type' => 'text','rights' => 'rrr'),
- 'name' => array('desc' => _ADSNAME, 'type' => 'text','rights' => 'rrr'),
- 'samaccountname' => array('desc' => _ADSSAMACCOUNTNAME, 'type' => 'text','rights' => 'wrr'),
- 'description' => array('desc' => _ADSDESCRIPTION, 'type' => 'text'),
- 'gidnumber' => array('desc' => _ADSGIDNUMBER, 'type' => 'int','rights' => 'w--'),
- 'member' => array('desc' => _ADSMEMBER, 'type' => 'select'),
- 'objectcategory' => array('desc' => _ADSOBJECTCATEGORY, 'type' => 'text','rights' => 'rrr'),
-
- 'memberuid' => array('desc' => _ADSMEMBERUID, 'type' => 'select'),
- );
-
-?>
diff --git a/mayor-orig/www/include/backend/ads/password/changePassword.php b/mayor-orig/www/include/backend/ads/password/changePassword.php
deleted file mode 100644
index 6d686b34..00000000
--- a/mayor-orig/www/include/backend/ads/password/changePassword.php
+++ /dev/null
@@ -1,165 +0,0 @@
-<?php
-/*
-
- Module: base/password
-
- Active Directory-ban csak ldaps-sel lehet megváltoztatni a jelszót!
- Az AD a shadow attribútumokat nem kezeli, helyettük más attribútumokat állít automatikusan.
- De azért beállítjuk őket, abból baj nem lehet...
-
- function changeMyPassword($userAccount, $userPassword, $newPassword, $verification)
- A függvény nem vizsgálja, hogy jogosultak vagyunk-e a jelszó megváltoztatására.
- Ennek eldöntése a függvényt hívó program feladata
-*/
-
-############################################################################
-# Jelszó kódolása az Active Directory számára
-############################################################################
-
-function ADSEncodePassword($password) {
-
- return mb_convert_encoding("\"".$password."\"", "UTF-16LE", "UTF-8");
-
-}
-
-############################################################################
-# Saját jelszó megváltoztatása
-############################################################################
-
-/* *************************************************************************
- A leírások szerint a felhasználó maga is megváltoztathatja jelszavát.
- Ennek módja az unicodePw attribútum törlése (a régi jelszó értéke szerint),
- és felvétele új értékkel - mindenz elvileg egy lépésben.
-
- A PHP ldap_mod* függvények ezt az egy lépésben kétféle módosítást nem
- támogatják. De a helyzet az, hogy a módosítás perl-ből és parancssorból
- sem működik...
-************************************************************************* */
-
-function changeMyPassword($userAccount, $userPassword, $newPassword, $toPolicy = '') {
-
- global $AUTH;
-
- if ($toPolicy == '') $toPolicy = $_REQUEST['toPolicy'];
- $userDn = ADSuserAccountToDn($userAccount, $toPolicy);
-
- // Csatlakozzás az AD kiszolgálóhoz (SSL szükséges!)
- $ds = ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- // nem sikerült csatlakozni
- $_SESSION['alert'][] = 'message:ldap_failure';
- return false;
- }
-
- // Az eredeti jelszó ellenőrzése - csatlakozással
- $b_ok = ldap_bind($ds,$userDn,$userPassword);
- if (!$b_ok) {
- // Talán a régi jelszót elgépelte, vagy le van tiltva...
- $_SESSION['alert'][] = 'message:ldap_bind_failure:'.$userDn.':changeMyPassword - hibás a régi jelszó?';
- ldap_close($ds);
- return false;
- }
-
- // A régi és új jelszavak átkódolása
- $newUnicodePwd = base64_encode(ADSEncodePassword($newPassword));
- $oldUnicodePwd = base64_encode(ADSEncodePassword($userPassword));
- // A php ldap_mod* függvényei nem tudnak egy lépésben többféle módosítást elküldeni
- // ezért a parancssoros ldapmodify-t kell meghívnunk...
- $ldif=<<<EOT
-dn: $userDn
-changetype: modify
-delete: unicodePwd
-unicodePwd:: $oldUnicodePwd
--
-add: unicodePwd
-unicodePwd:: $newUnicodePwd
--
-EOT;
- $cmd = sprintf("/usr/bin/ldapmodify -H %s -D '%s' -x -w %s", $AUTH[$toPolicy]['adsHostname'], $userDn, $userPassword);
- // KHM!
- if (($fh = popen($cmd, 'w')) === false ) {
- // Nem sikerült megnyitni a csatornát - mikor is lehet ilyen? Ha nincs ldapmodify?
- $_SESSION['alert'][] = 'message:popen_failure';
- return false;
- }
- fwrite($fh, "$ldif\n");
- pclose($fh);
-
- // Sikeres volt-e a jelszóváltoztatás? Próbáljunk újra csatlakozni az új jelszóval!
- if (!@ldap_bind($ds, $userDn, $newPassword)) {
- $_SESSION['alert'][] = 'message:bad_pw';
- return false;
- }
-
- // Shadow attribútumok beállítása
- // Ezekre nincs jogosultsága a felhasználónak, így csak AccountOperator-ként módosítható
- // Ráadásul Windoes alatt változtatva a jelszót ezek nem változnak, így nem lehet számítani rájuk...
- if (isset($AUTH[$toPolicy]['adsAccountOperatorUser'])) {
- $shadowLastChange = floor(time()/(60*60*24));
- $info['shadowLastChange'][0] = $shadowLastChange;
- if (isset($AUTH[$toPolicy]['shadowExpire']) and $AUTH[$toPolicy]['shadowExpire'] != '') {
- $info['shadowExpire'][0] = $AUTH[$toPolicy]['shadowExpire'];
- } elseif (isset($AUTH[$toPolicy]['shadowMax']) and $AUTH[$toPolicy]['shadowMax'] != '') {
- $info['shadowExpire'][0] = $shadowLastChange + intval($AUTH[$toPolicy]['shadowMax']);
- }
-
- $b_ok = ldap_bind($ds,$AUTH[$toPolicy]['adsAccountOperatorUser'],$AUTH[$toPolicy]['adsAccountOperatorPw']);
- if (!$b_ok) { $_SESSION['alert'][] = 'message:ldap_bind_failure'; return false; }
- $r = @ldap_mod_replace($ds, $userDn, $info);
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_modify_failure:changeMyPassword';
- return false;
- }
- }
- ldap_close($ds);
- $_SESSION['alert'][] = 'info:pw_change_success';
- return true;
-
-}
-
-############################################################################
-# Adminisztrátori jelszó változtatás
-############################################################################
-
-function changePassword($userAccount, $newPassword, $toPolicy = '') {
-
- global $AUTH;
-
- if ($toPolicy == '') $toPolicy = _POLICY;
- $userDn = ADSuserAccountToDn($userAccount, $toPolicy);
- $shadowLastChange = floor(time()/(60*60*24));
-
- $ds = ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if ($ds) {
- $b_ok = ldap_bind($ds,BACKEND_CONNECT_DN,BACKEND_CONNECT_PASSWORD);
- if ($b_ok) {
- $info['unicodePwd'][0] = ADSEncodePassword($newPassword);
- // Ezekre nincs jogosultsága a felhasználónak, nem változnak:
- // _SHADOWMIN, _SHADOWMAX, _SHADOWWARNING, _SHADOWINACTIVE
- $info['shadowLastChange'][0] = $shadowLastChange;
- if (isset($AUTH[$toPolicy]['shadowExpire']) and $AUTH[$toPolicy]['shadowExpire'] != '') {
- $info['shadowExpire'][0] = $AUTH[$toPolicy]['shadowExpire'];
- } elseif (isset($AUTH[$toPolicy]['shadowMax']) and $AUTH[$toPolicy]['shadowMax'] != '') {
- $info['shadowExpire'][0] = $shadowLastChange + intval($AUTH[$toPolicy]['shadowMax']);
- }
- $r = @ldap_mod_replace($ds,$userDn,$info);
- ldap_close($ds);
- if ($r) {
- $_SESSION['alert'][] = 'info:pw_change_success';
- return true;
- } else {
- $_SESSION['alert'][] = 'message:ldap_modify_failure:changePassword';
- return false;
- }
- } else {
- $_SESSION['alert'][] = 'message:ldap_bind_failure:'._USERDN.':changePassword';
- ldap_close($ds);
- return false;
- }
- } else {
- $_SESSION['alert'][] = 'message:ldap_failure';
- return false;
- }
-}
-
-?>
diff --git a/mayor-orig/www/include/backend/ads/session/accountInfo.php b/mayor-orig/www/include/backend/ads/session/accountInfo.php
deleted file mode 100644
index eef90fd4..00000000
--- a/mayor-orig/www/include/backend/ads/session/accountInfo.php
+++ /dev/null
@@ -1,416 +0,0 @@
-<?php
-/*
- Module: base/auth-ads
- Backend: ads
-
- function getADSInfo($userDn, $attrList=array('cn'), $toPolicy = '')
- function adsGetAccountInfo($userAccount, $toPolicy = _POLICY)
- function adsGetUserInfo($userAccount, $toPolicy = _POLICY)
- function adsChangeAccountInfo($userAccount, $toPolicy = _POLICY)
- function adsGetGroupInfo($groupCn, $toPolicy = _POLICY)
-
-*/
-
-######################################################
-# getADSInfo - általános ADS lekérdezés
-######################################################
-
-
- function getADSInfo($userDn, $attrList=array('cn'), $toPolicy = _POLICY) {
-
- global $AUTH;
-
- // Kapcsolódás az ADS szerverhez
- $ds = @ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- $_SESSION['alert'][] = 'alert:ldap_connect_failure';
- return false;
- }
-
- // Csatlakozás a szerverhez
- $r = @ldap_bind($ds, BACKEND_CONNECT_DN,BACKEND_CONNECT_PASSWORD);
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_bind_failure';
- ldap_close($ds);
- return false;
- }
-
- // Keresés
- $filter = '(objectclass=*)';
- $sr = @ldap_search($ds, $userDn, $filter, $attrList);
- if (!$sr) {
- $_SESSION['alert'][] = "message:ldap_search_failure:".$userDn;
- ldap_close($ds);
- return false;
- }
-
- $info = @ldap_get_entries($ds,$sr);
- ldap_close($ds);
-
- return $info;
-
- }
-
-###########################################################
-# adsGetAccountInfo - felhasználói információk (backend)
-###########################################################
-
- function adsGetAccountInfo($userAccount, $toPolicy = _POLICY) {
-
- global $backendAttrs, $backendAttrDef;
-
- if (!isset($backendAttrs)) list($backendAttrs, $backendAttrDef) = getBackendAttrs('Account', $toPolicy);
-
- $userDn = ADSuserAccountToDn($userAccount, $toPolicy);
-
- $result = getADSInfo($userDn, $backendAttrs, $toPolicy);
- if ($result === false) {
- return false;
- } else {
-
- // ADS schema --> mayor schema konverzió
- for ($i = 0; $i < $result['count']; $i++) {
- // Egységes szerkezetre alakítjuk, azaz a dn is indexelt
- foreach ($backendAttrDef as $attr => $def) {
- // Egységes szerkezetre alakítjuk, azaz a dn is indexelt
- if ($attr == 'dn') $return[$i]['dn'] = array('count' => 1, 0 => $result[$i]['dn']);
- elseif (isset($result[$i][$attr])) $return[$i][$attr] = $result[$i][$attr];
- else $return[$i][$attr] = array('count' => 0);
- }
- }
- return $return[0];
-
- }
-
- }
-
-#############################################################
-# adsGetUserInfo - felhasználói információk (keretrendszer)
-#############################################################
-
- function adsGetUserInfo($userAccount, $toPolicy = _POLICY) {
-
- global $accountAttrToADS, $adsAttrDef;
- $userDn = ADSuserAccountToDn($userAccount, $toPolicy);
-
- $result = getADSInfo($userDn, array_values($accountAttrToADS), $toPolicy);
- if ($result === false) {
- return false;
- } else {
-
- $result[0]['dn'] = array('count' => 1, 0 => $result[0]['dn']);
- // Egységes szerkezetre alakítjuk, azaz a dn is indexelt + ADS --> MaYoR schema
- foreach ($accountAttrToADS as $attr => $adsAttr) {
- $adsAttr = kisbetus($adsAttr);
- if (isset($result[0][$adsAttr])) $return[$attr] = $result[0][$adsAttr];
- else $return[$attr] = array('count' => 0);
- }
- return $return;
-
- }
-
- }
-
-###############################################################
-# adsChangeAccountInfo - felhasználói információk módosítása
-###############################################################
-
- function adsChangeAccountInfo($userAccount, $toPolicy = _POLICY) {
-
- global $AUTH, $backendAttrs, $backendAttrDef;
- $userDn = ADSuserAccountToDn($userAccount, $toPolicy);
-
- // Kapcsolódás az ADS szerverhez
- $ds = @ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- $_SESSION['alert'][] = 'alert:ldap_connect_failure';
- return false;
- }
-
- // Csatlakozás a szerverhez
- $r = @ldap_bind($ds, BACKEND_CONNECT_DN,BACKEND_CONNECT_PASSWORD);
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_bind_failure';
- ldap_close($ds);
- return false;
- }
-
- $emptyAttrs = explode(':',$_POST['emptyAttrs']);
- $_alert = array();
-
- // Attribútumonként módosítunk
- foreach ($backendAttrs as $attr) {
-
- if ($backendAttrDef[$attr]['rights'] == '') $rigths = _DEFAULT_ADS_RIGHTS;
- else $rights = $backendAttrDef[$attr]['rights'];
-
- if ($rights[_ACCESS_AS] == 'w') {
- $mod_info = $add_info = $del_info = Array();
- $values = array();
-
- if ($backendAttrDef[$attr]['type'] == 'image') {
- $file = $_FILES[$attr]['tmp_name'];
- if (file_exists($file)) {
- $fd = fopen($file,'r');
- $values[0]=fread($fd,filesize($file));
- fclose($fd);
- } else {
- // Sose töröljük!
- $emptyAttrs[] = $attr;
- }
- } elseif ($backendAttrDef[$attr]['type'] == 'timestamp') {
- if ($_POST[$attr][0] != '' and $_POST[$attr][1] != '' and $_POST[$attr][2] != '') {
- $values[0] = $_POST[$attr][0].$_POST[$attr][1].$_POST[$attr][2].'010101Z';
- }
- } else {
- if ($backendAttrDef[$attr]['type'] != '' ) $values[0] = $_POST[$attr];
- }
-
- if ($backendAttrDef[$attr]['type'] == 'select') {
- if ($_POST['new-'.$attr][0] != '') $add_info[$attr] = $_POST['new-'.$attr];
- if ($_POST['del-'.$attr][0] != '') $del_info[$attr] = $_POST['del-'.$attr];
- } elseif (in_array($attr,$emptyAttrs)) {
- if ($values[0] != '') $add_info[$attr] = $values;
- } else {
- if ($values[0] != '') {
- $mod_info[$attr] = $values;
- } else {
- $del_info[$attr] = Array();
- }
- }
-
- if (count($add_info)!=0) {
- if (!@ldap_mod_add($ds,$userDn,$add_info)) {
- $_alert[] = 'message:insufficient_access:add:'.$attr;
- }
- }
- if (count($mod_info)!=0) {
- if (!@$r = ldap_mod_replace($ds,$userDn,$mod_info)) {
- $_alert[] = 'message:insufficient_access:mod:'.$attr;
- }
- }
- if (count($del_info)!=0) {
- if (!@ldap_mod_del($ds,$userDn,$del_info)) {
- $_alert[] = 'message:insufficient_access:del:'.$attr;
- }
- }
-
- } else {
-// $_alert[] = 'message:insufficient_access:'.$attr;
- }
- } // foreach
-
- ldap_close($ds);
- if (count($_alert) == 0) $_SESSION['alert'][] = 'info:change_success';
- else for ($i = 0;$i < count($_alert);$i++) $_SESSION['alert'][] = $_alert[$i];
-
- }
-
-###########################################################
-# adsGetGroupInfo - csoport információk (backend)
-###########################################################
-
- function adsGetGroupInfo($groupCn, $toPolicy = _POLICY, $SET = array()) {
-
- global $backendAttrs, $backendAttrDef;
-
-
- if (!isset($backendAttrs)) list($backendAttrs, $backendAttrDef) = getBackendAttrs('Group', $toPolicy);
-
- $groupDn = ADSgroupCnToDn($groupCn, $toPolicy);
-
- $result = getADSInfo($groupDn, $backendAttrs, $toPolicy);
- if ($result === false) {
- return false;
- } else {
-
- // Accountok lekérdezése
- $info = getADSaccounts($toPolicy);
- for ($i = 0; $i < $info['count']; $i++) {
- $accountUid[] = array(
- 'value' => $info[$i]['uid'][0],
- 'txt' => $info[$i]['displayname'][0]
- );
- $accountDn[] = array(
- 'value' => $info[$i]['dn'],
- 'txt' => $info[$i]['displayname'][0]
- );
- $DN2CN[$info[$i]['dn']] = $info[$i]['displayname'][0];
- }
-
- // ADS schema --> mayor schema konverzió
- for ($i = 0; $i < $result['count']; $i++) {
- // Egységes szerkezetre alakítjuk, azaz a dn is indexelt
- foreach ($backendAttrDef as $attr => $def) {
- // Egységes szerkezetre alakítjuk, azaz a dn is indexelt
- if ($attr == 'dn') $return[$i]['dn'] = array('count' => 1, 0 => $result[$i]['dn']);
- elseif($attr == 'member') {
- $_TMP = array();
- for ($j=0; $j<$result[$i][$attr]['count']; $j++) {
- $_dn = $result[$i][$attr][$j];
- $_TMP[] = array(
- 'type'=>'member',
- 'value'=>$_dn,
- 'txt'=>($DN2CN[$_dn]==''?str_replace(',',' ',$_dn):$DN2CN[$_dn])
- );
- }
- $return[$i][$attr] = $_TMP;
- }
-
- elseif (isset($result[$i][$attr])) $return[$i][$attr] = $result[$i][$attr];
- else $return[$i][$attr] = array('count' => 0);
- }
-
- if ($SET['withNewAccounts']===true) {
- $return[$i]['member']['new'] = $accountDn;
- $return[$i]['memberuid']['new'] = $accountUid;
- }
- }
-
- return $return[0];
-
- }
-
- }
-
-###############################################################
-# adsChangeGroupInfo - csoport információk módosítása
-###############################################################
-
- function adsChangeGroupInfo($groupCn, $toPolicy = _POLICY) {
-
-// !!!! A memberuid / member szinkronjára nem figyel!!
-
- global $AUTH, $backendAttrs, $backendAttrDef;
- $groupDn = ADSgroupCnToDn($groupCn, $toPolicy);
-
- // Kapcsolódás az ADS szerverhez
- $ds = @ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- $_SESSION['alert'][] = 'alert:ldap_connect_failure';
- return false;
- }
-
- // Csatlakozás a szerverhez
- $r = @ldap_bind($ds, BACKEND_CONNECT_DN,BACKEND_CONNECT_PASSWORD);
-
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_bind_failure';
- ldap_close($ds);
- return false;
- }
-
- $emptyAttrs = explode(':',$_POST['emptyAttrs']);
- $_alert = array();
-
- // Attribútumonként módosítunk
- foreach ($backendAttrs as $attr) {
-
- if ($backendAttrDef[$attr]['rights'] == '') $rigths = _DEFAULT_ADS_RIGHTS;
- else $rights = $backendAttrDef[$attr]['rights'];
-
- if ($rights[_ACCESS_AS] == 'w') {
-
- $mod_info = $add_info = $del_info = Array();
- $values = array();
-
- if ($backendAttrDef[$attr]['type'] == 'image') {
- $file = $_FILES[$attr]['tmp_name'];
- if (file_exists($file)) {
- $fd = fopen($file,'r');
- $values[0]=fread($fd,filesize($file));
- fclose($fd);
- } else {
- // Sose töröljük!
- $emptyAttrs[] = $attr;
- }
- } elseif ($backendAttrDef[$attr]['type'] == 'timestamp') {
- if ($_POST[$attr][0] != '' and $_POST[$attr][1] != '' and $_POST[$attr][2] != '') {
- $values[0] = $_POST[$attr][0].$_POST[$attr][1].$_POST[$attr][2].'010101Z';
- }
- } else {
- if ($backendAttrDef[$attr]['type'] != '')
- if (isset($_POST[$attr])) $values[0] = $_POST[$attr];
- else $values[0] = '';
- }
-
- if ($backendAttrDef[$attr]['type'] == 'select') {
- if (isset($_POST['new-'.$attr][0]) && $_POST['new-'.$attr][0] != '') $add_info[$attr] = $_POST['new-'.$attr];
- if (isset($_POST['del-'.$attr][0]) && $_POST['del-'.$attr][0] != '') $del_info[$attr] = $_POST['del-'.$attr];
- } elseif (in_array($attr,$emptyAttrs)) {
- if ($values[0] != '') $add_info[$attr] = $values;
- } else {
- if ($values[0] != '') {
- $mod_info[$attr] = $values;
- } else {
- $del_info[$attr] = Array();
- }
-
- }
-
- if (count($add_info)!=0) {
- if (!@ldap_mod_add($ds,$groupDn,$add_info)) {
- $_alert[] = 'message:insufficient_access:add:'.$attr;
- }
- }
- if (count($mod_info)!=0) {
- if (!@ldap_mod_replace($ds,$groupDn,$mod_info)) {
- $_alert[] = 'message:insufficient_access:mod:'.$attr;
- }
- }
- if (count($del_info)!=0) {
- if (!@ldap_mod_del($ds,$groupDn,$del_info)) {
- $_alert[] = 'message:insufficient_access:del:'.$attr;
- }
- }
-
- } else {
-// $_alert[] = 'message:insufficient_access:'.$attr;
- }
- } // foreach
-
- ldap_close($ds);
- if (count($_alert) == 0) $_SESSION['alert'][] = 'info:change_success';
- else for ($i=0;$i<count($_alert);$i++) $_SESSION['alert'][] = $_alert[$i];
-
- }
-
- function getADSaccounts($toPolicy = _POLICY) {
-
- global $AUTH;
-
- // Kapcsolódás az ADS szerverhez
- $ds = @ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- $_SESSION['alert'][] = 'alert:ldap_connect_failure';
- return false;
- }
-
- // Csatlakozás a szerverhez
- $r = @ldap_bind($ds, BACKEND_CONNECT_DN,BACKEND_CONNECT_PASSWORD);
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_bind_failure';
- ldap_close($ds);
- return false;
- }
-
- // Keresés
- $attrList = array('cn','uid','displayName','samaccountname');
- $filter = '(&(objectclass=person)(!(objectclass=computer)))';
- $sr = @ldap_search($ds, $AUTH[$toPolicy]['adsBaseDn'], $filter, $attrList);
- if (!$sr) {
- $_SESSION['alert'][] = "message:ldap_search_failure:".$userDn;
- ldap_close($ds);
- return false;
- }
-
- ldap_sort($ds, $sr, 'displayname');
- $info = @ldap_get_entries($ds,$sr);
- ldap_close($ds);
-
- return $info;
-
- }
-
-
-?>
diff --git a/mayor-orig/www/include/backend/ads/session/base.php b/mayor-orig/www/include/backend/ads/session/base.php
deleted file mode 100644
index 3a727c3b..00000000
--- a/mayor-orig/www/include/backend/ads/session/base.php
+++ /dev/null
@@ -1,188 +0,0 @@
-<?php
-/*
- Module: base/session
- Backend: ads (for Active Directory)
-
- function ADSuserAccountToDn($userAccount = _USERACCOUNT, $toPolicy = _POLICY)
- function adsMemberOf($userAccount, $group, $toPolicy = _POLICY)
-
-*/
-
- require('include/backend/ads/base/attrs.php');
-
- ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, 3);
- ldap_set_option(NULL, LDAP_OPT_REFERRALS, 0);
-
- if ($AUTH[_POLICY]['backend'] == 'ads') {
- /* why not put into session cache */
- if ($AUTH[_POLICY]['cacheable']=='yes') {
- $userDn = _queryCache('RDN',_POLICY,'value');
- }
- if (!isset($userDn)) $userDn = ADSuserAccountToDn();
- define('_USERDN', $userDn); // --TODO DEPRECATED
- define('BACKEND_CONNECT_DN', $AUTH[_POLICY]['adsUser']);
- define('BACKEND_CONNECT_PASSWORD', $AUTH[_POLICY]['adsPw']);
- if ($AUTH[_POLICY]['cacheable']=='yes') _registerToCache('RDN',$userDn,_POLICY);
- unset($userDn);
- }
-
-######################################################
-# A _USERACCOUNT(uid)-hoz tartozó dn lekérdezése
-######################################################
-
- function ADSuserAccountToDn($userAccount = _USERACCOUNT, $toPolicy = _POLICY) {
-
- global $AUTH;
-
- // Kapcsolódás a szerverhez
- $ds = @ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- $_SESSION['alert'][] = 'alert:ldap_connect_failure';
- return false;
- }
-
- // Csatlakozás a szerverhez
- $r = @ldap_bind($ds,$AUTH[$toPolicy]['adsUser'],$AUTH[$toPolicy]['adsPw']);
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_bind_failure';
- return false;
- }
-
- // Van-e adott azonosítójú felhasználó?
- $filter="(&(sAMAccountName=$userAccount)(objectClass=".$AUTH[$toPolicy]['adsUserObjectClass']."))";
- $justthese=array('cn','sn','givenName');
- $sr = ldap_search($ds, $AUTH[$toPolicy]['adsBaseDn'], $filter, $justthese);
- if (!$sr) {
- $_SESSION['alert'][] = "message:ldap_search_failure";
- ldap_close($ds);
- return false;
- }
- $info=ldap_get_entries($ds,$sr);
- ldap_close($ds);
-
- if ( $info['count'] === 0 ) {
- // Nincs ilyen userAccount (uid)
- $_SESSION['alert'][] = "message:no_account:$userAccount";
- return false;
- } elseif ( $info['count'] > 1 ) {
- // Több ilyen uid is van
- $_SESSION['alert'][] = "message:multi_uid:$userAccount";
- return false;
- }
-
- if ($info['count']==1) { // Van - egy - ilyen felhasználó
- return $info[0]['dn'];
- }
-
- }
-
-
-######################################################
-# A groupCn(cn)-hez tartozó dn lekérdezése
-######################################################
-
- function ADSgroupCnToDn($groupCn, $toPolicy = _POLICY) {
-
- global $AUTH;
-
- // Kapcsolódás a szerverhez
- $ds = @ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- $_SESSION['alert'][] = 'alert:ldap_connect_failure';
- return false;
- }
-
- // Csatlakozás a szerverhez
- $r = @ldap_bind($ds,$AUTH[$toPolicy]['adsUser'],$AUTH[$toPolicy]['adsPw']);
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_bind_failure';
- return false;
- }
-
- // Van-e ilyen csoport?
- $filter="(&(cn=$groupCn)(objectClass=".$AUTH[$toPolicy]['adsGroupObjectClass']."))";
- $justthese=array('cn');
- $sr = ldap_search($ds, $AUTH[$toPolicy]['adsBaseDn'], $filter, $justthese);
- if (!$sr) {
- $_SESSION['alert'][] = "message:ldap_search_failure";
- ldap_close($ds);
- return false;
- }
- $info=ldap_get_entries($ds,$sr);
- ldap_close($ds);
-
- if ( $info['count'] === 0 ) {
- // Nincs ilyen groupCn (cn) - hibaüzenet csak akkor, ha nem kategóriáról van szó...
- if (!in_array($groupCn, array_map('ekezettelen', $AUTH[$toPolicy]['categories']))) $_SESSION['alert'][] = "message:no_group:$groupCn";
- return false;
- } elseif ( $info['count'] > 1 ) {
- // Több ilyen cn is van
- $_SESSION['alert'][] = "message:multi_gid:$groupCn";
- return false;
- }
-
- if ($info['count']==1) { // Van - egy - ilyen csoport
- return $info[0]['dn'];
- }
-
- }
-
-######################################################
-# memberOf - csoport tag-e
-######################################################
-
- function adsMemberOf($userAccount, $group, $toPolicy = _POLICY) {
-
- global $AUTH;
- //global $ADS2Mayor;
-
- $userDn = ADSuserAccountToDn($userAccount, $toPolicy);
- if (in_array($group, $AUTH[$toPolicy]['categories'])) {
- if (strpos($userDn, ',ou='.ekezettelen($group).',') !== false) return true;
-# Ha nincs megfelelő ou-ban, akkor nézzük a csoport tagságot - így berakható időszakosan akárki pl a titkárság kategóriába...
-# else return false;
- }
-
- if (substr($group,0,3) != 'cn=') {
- $groupDn = ADSgroupCnToDn(ekezettelen($group));
- if (!$groupDn) return false; // Ha nincs ilyen csoport az ADS fában
- } else {
- $groupDn = $group;
- }
-
- // Kapcsolódás az ADS szerverhez
- $ds = @ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- $_SESSION['alert'][] = 'alert:ldap_connect_failure';
- return false;
- }
-
- // Csatlakozás a szerverhez
- $r = @ldap_bind($ds,$AUTH[$toPolicy]['adsUser'],$AUTH[$toPolicy]['adsPw']);
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_bind_failure';
- ldap_close($ds);
- return false;
- }
-
- $justthese = array('cn'); // valamit le kell kérdezni...
- $filter = "(&(objectClass=".$AUTH[$toPolicy]['adsGroupObjectClass'].")(member=$userDn))";
- $sr = @ldap_search($ds, $groupDn, $filter, $justthese);
- if (!$sr) {
- $_SESSION['alert'][] = "message:ldap_search_failure:".$filter;
- ldap_close($ds);
- return false;
- }
-
- $info = ldap_get_entries($ds, $sr);
- ldap_close($ds);
-
- if ($info['count'] > 0) {
- return true;
- } else {
- return false;
- }
-
- }
-
-?>
diff --git a/mayor-orig/www/include/backend/ads/session/createAccount.php b/mayor-orig/www/include/backend/ads/session/createAccount.php
deleted file mode 100644
index 02809f07..00000000
--- a/mayor-orig/www/include/backend/ads/session/createAccount.php
+++ /dev/null
@@ -1,157 +0,0 @@
-<?php
-/*
- Modules: base/session
-*/
-
- require_once('include/backend/ads/password/changePassword.php');
-
- /*
- $SET = array(
- container => a konténer elem - ha nincs, akkor CN=Users alá rakja
- category => tanár, diák... egy kiemelt fontosságú csoport tagság
- groups => egyéb csoportok
- policyAttrs => policy függő attribútumok
- )
- */
- function adsCreateAccount(
- $userCn, $userAccount, $userPassword, $toPolicy, $SET
- ) {
-
- global $AUTH;
-
- $shadowLastChange = floor(time() / (60*60*24));
-
- // $toPolicy --> ads backend - ellenőrzés!
- if ($AUTH[$toPolicy]['backend'] != 'ads') {
- $_SESSION['alert'][] = 'page:wrong_backend:'.$AUTH[$toPolicy]['backend'];
- return false;
- }
-
- // Kapcsolódás az LDAP szerverhez
- $ds = @ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- $_SESSION['alert'][] = 'alert:ldap_connect_failure';
- return false;
- }
-
- // Csatlakozás a szerverhez
- $r = @ldap_bind($ds, BACKEND_CONNECT_DN,BACKEND_CONNECT_PASSWORD);
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_bind_failure';
- ldap_close($ds);
- return false;
- }
-
- $info = $ginfo = Array();
-
- // uid ütközés ellenőrzése
- $filter = "(sAMAccountName=$userAccount)";
- $justthese = array('sAMAccountName');
- $sr = ldap_search($ds, $AUTH[$toPolicy]['adsBaseDn'], $filter, $justthese);
- $uinfo = ldap_get_entries($ds, $sr);
- $uidCount = $uinfo['count'];
- ldap_free_result($sr);
- if ($uidCount > 0) {
- $_SESSION['alert'][] = 'message:multi_uid:'.$userAccount;
- return false;
- }
-
- // Az következő uidNumber megállapítása
- $filter = "(&(objectclass=".$AUTH[$toPolicy]['adsUserObjectClass'].")(uidNumber=*))";
- $justthese = array('uidNumber', 'msSFU30UidNumber');
- $sr = ldap_search($ds,$AUTH[$toPolicy]['adsBaseDn'], $filter, $justthese);
- ldap_sort($ds, $sr, 'uidNumber');
- $uinfo = ldap_get_entries($ds, $sr);
- ldap_free_result($sr);
- if (isset($uinfo['count']) && $uinfo['count'] > 0) $info['uidNumber'] = array($uinfo[ $uinfo['count']-1 ]['uidnumber'][0]+1);
- else $info['uidNumber'] = array(1001);
-
- // shadow attributumok...
- // A shadowLastChange a mai nap // if (isset($AUTH[$toPolicy]['shadowlastchange']) && $AUTH[$toPolicy]['shadowlastchange'] != '')
- $info['shadowLastChange'] = array($shadowLastChange);
- if (isset($AUTH[$toPolicy]['shadowMin']) && $AUTH[$toPolicy]['shadowMin'] != '') $info['shadowMin'] = array($AUTH[$toPolicy]['shadowMin']);
- if (isset($AUTH[$toPolicy]['shadowMax']) && $AUTH[$toPolicy]['shadowMax'] != '') $info['shadowMax'] = array($AUTH[$toPolicy]['shadowMax']);
- if (isset($AUTH[$toPolicy]['shadowWarning']) && $AUTH[$toPolicy]['shadowWarning'] != '') $info['shadowWarning'] = array($AUTH[$toPolicy]['shadowWarning']);
- if (isset($AUTH[$toPolicy]['shadowInactive']) && $AUTH[$toPolicy]['shadowInactive'] != '') $info['shadowInactive'] = array($AUTH[$toPolicy]['shadowInactive']);
- if (isset($AUTH[$toPolicy]['shadowExpire']) && $AUTH[$toPolicy]['shadowWxpire'] != '') $info['shadowExpire'] = array($AUTH[$toPolicy]['shadowExpire']);
-
- // A szokásos attribútumok
- $Name = explode(' ',$userCn);
- $Dn = ldap_explode_dn($AUTH[$toPolicy]['adsBaseDn'], 1); unset($Dn['count']);
- $info['userPrincipalName'] = array( $userAccount.'@'.implode('.', $Dn));
- $info['msSFU30Name'] = $info['sAMAccountName'] = $info['cn'] = array($userAccount);
- $info['displayName'] = array($userCn);
- $info['sn'] = array($Name[0]);
- $info['givenName'] = array($Name[ count($Name)-1 ]);
- $info['unixUserPassword'] = array('ABCD!efgh12345$67890');
- $info['unixHomeDirectory'] = array(ekezettelen("/home/$userAccount"));
- $info['loginShell'] = array('/bin/bash');
- $info['objectClass'] = array($AUTH[$toPolicy]['adsUserObjectClass'], 'user');
-
- $policyAccountAttrs = $SET['policyAttrs'];
- if (isset($policyAccountAttrs['studyId'])) $info[ $AUTH[$toPolicy]['adsStudyIdAttr'] ] = array($policyAccountAttrs['studyId']);
- foreach ($policyAccountAttrs as $attr => $value)
- if ($attr != 'studyId' && isset($accountAttrToADS[$attr]))
- $info[ $accountAttrToADS[$attr] ] = array($value);
-
- if (isset($SET['container'])) $dn = "CN=$userAccount,".$SET['container'];
- else $dn = "CN=$userAccount,CN=Users,".$AUTH[$toPolicy]['adsBaseDn'];
-
- // user felvétel
- $_r1 = @ldap_add($ds,$dn,$info);
- if (!$_r1) {
- $_SESSION['alert'][] = 'message:ldap_error:Add user:'.ldap_error($ds);
- //echo $dn.'<pre>'; var_dump($info); echo '</pre>';
- return false;
- }
-
- // Jelszó beállítás
- if (!changePassword($userAccount, $userPassword, $toPolicy)) $_SESSION['alert'][] = 'message:ldap_error:changePassword failed:'.$userAccount;
-
- // Engedélyezés
- $einfo = array('userAccountControl' => array(512)); /* Normal account = 512 */
- $_r1 = @ldap_mod_replace($ds,$dn,$einfo);
- if (!$_r1) {
- $_SESSION['alert'][] = 'message:ldap_error:Enable user:'.ldap_error($ds);
- //echo $dn.'<pre>'; var_dump($info); echo '</pre>';
- return false;
- }
-
- // Kategória csoportba és egyéb csoportokba rakás
- if (isset($SET['category'])) {
- if (is_array($SET['groups'])) array_unshift($SET['groups'], $SET['category']);
- else $SET['groups'] = array($SET['category']);
-
- $ginfo['member'] = $dn;
-
- for ($i = 0; $i < count($SET['groups']); $i++) {
- $groupDn = ADSgroupCnToDn($SET['groups'][$i], $toPolicy);
- if ($groupDn !== false) {
- $_r3 = @ldap_mod_add($ds, $groupDn, $ginfo);
- if (!$_r3) {
- $_SESSION['alert'][] = 'message:ldap_error:Add to group '.$SET['groups'][$i].':'.ldap_error($ds);
- //echo $SET['groups'][$i].'<pre>'; var_dump($ginfo); echo '</pre>';
- }
- }
- }
- }
-
- ldap_close($ds);
-
- if (defined('_DATADIR')
- && isset($AUTH[$toPolicy]['createAccountScript'])
- && file_exists(_DATADIR)
- ) {
- $sfp = fopen(_DATADIR.'/'.$AUTH[$toPolicy]['createAccountScript'],'a+');
- if ($sfp) {
- fwrite($sfp,"\n# $userAccount létrehozása: userAccount uidNumber homeDirectory\n");
- fwrite($sfp,"createAccount.sh '$userAccount' '".$info['uidNumber'][0]."' '".$info['unixHomeDirectory'][0]."'\n");
- fclose($sfp);
- }
- }
- $_SESSION['alert'][] = 'info:create_uid_success:'.$dn;
- return true;
-
- }
-
-?>
diff --git a/mayor-orig/www/include/backend/ads/session/createGroup.php b/mayor-orig/www/include/backend/ads/session/createGroup.php
deleted file mode 100644
index 0a0a8c1d..00000000
--- a/mayor-orig/www/include/backend/ads/session/createGroup.php
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php
-/*
- Modules: base/session
-*/
-
-
- function adsCreateGroup($groupCn, $groupDesc, $toPolicy = _POLICY, $SET = array()) {
-
- global $AUTH;
- $category = ekezettelen($SET['category']);
-
- // $toPolicy --> ads backend - ellenőrzés!
- if ($AUTH[$toPolicy]['backend'] != 'ads') {
- $_SESSION['alert'][] = 'page:wrong_backend:'.$AUTH[$toPolicy]['backend'];
- return false;
- }
-
- // Kapcsolódás az LDAP szerverhez
- $ds = @ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- $_SESSION['alert'][] = 'alert:ldap_connect_failure';
- return false;
- }
-
- // Csatlakozás a szerverhez
- $r = @ldap_bind($ds, BACKEND_CONNECT_DN,BACKEND_CONNECT_PASSWORD);
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_bind_failure';
- ldap_close($ds);
- return false;
- }
-
- $info = $ginfo = Array();
-
- // cn ütközés ellenőrzése
- $filter = "(&(objectclass=".$AUTH[$toPolicy]['adsGroupObjectClass'].")(cn=$groupCn))";
- $justthese = array('cn');
- $sr = ldap_search($ds, $AUTH[$toPolicy]['adsBaseDn'], $filter, $justthese);
- $ginfo = ldap_get_entries($ds, $sr);
- $gCount = $ginfo['count'];
- ldap_free_result($sr);
- if ($gCount > 0) {
- $_SESSION['alert'][] = 'message:multi_uid:'.$groupCn;
- return false;
- }
-
- // Az következő gidNumber megállapítása
- $filter = "(&(objectclass=".$AUTH[$toPolicy]['adsGroupObjectClass'].")(gidNumber=*))";
- $justthese = array('gidNumber', 'msSFU30GidNumber');
- $sr = ldap_search($ds,$AUTH[$toPolicy]['adsBaseDn'], $filter, $justthese);
- ldap_sort($ds, $sr, 'gidNumber');
- $ginfo = ldap_get_entries($ds, $sr);
- ldap_free_result($sr);
- if (isset($ginfo['count']) && $ginfo['count'] > 0) $info['gidNumber'] = array($ginfo[ $ginfo['count']-1 ]['gidnumber'][0]+1);
- else $info['gidNumber'] = array(1001);
-
- // A szokásos attribútumok
- $info['sAMAccountName'] = $info['cn'] = array($groupCn);
- $info['description'] = array($groupDesc);
-
- // A kategória függő attribútumok
- if (isset($SET['container'])) $dn = "CN=$groupCn,".$SET['container'];
- else $dn = "CN=$groupCn,OU=$category,".$AUTH[$toPolicy]['adsBaseDn'];
-
- // objectum osztályok
- $info['objectClass'] = array($AUTH[$toPolicy]['adsGroupObjectClass']);
-
- // csoport felvétel
- $_r1 = ldap_add($ds,$dn,$info);
- if (!$_r1) {
- printf("ADS-Error: %s<br>\n", ldap_error($ds));
- var_dump($info);
- }
-
- ldap_close($ds);
-
- $_SESSION['alert'][] = 'info:create_group_success:'.$dn;
- return true;
-
- }
-
-?>
diff --git a/mayor-orig/www/include/backend/ads/session/search/searchAccount.php b/mayor-orig/www/include/backend/ads/session/search/searchAccount.php
deleted file mode 100644
index 01298382..00000000
--- a/mayor-orig/www/include/backend/ads/session/search/searchAccount.php
+++ /dev/null
@@ -1,277 +0,0 @@
-<?php
-/*
- Module: base/session
- Backend: ads
-
- ! -- Csak publikus mezőkre lehet keresni! -- !
- function ADSSearch($attr, $pattern, $searchAttrs=array('cn'), $filter='(objectclass=*)')
- function adsSearchAccount($attr, $pattern, $searchAttrs = array('userCn'))
- function adsSearchGroup($attr, $pattern, $searchAttrs = array('groupCn, groupDesc'), $toPolicy = '') {
-
-*/
-
-######################################################
-# Általános ADS kereső függvény
-######################################################
-
- function ADSSearch($attr, $pattern, $searchAttrs=array('cn'), $filter='(objectclass=*)', $toPolicy = _POLICY) {
-
- global $AUTH;
-
- if ($pattern == '') {
- $_SESSION['alert'][] = 'message:empty_field';
- return false;
- }
-
- // Kapcsolódás az ADS szerverhez
- $ds = @ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- $_SESSION['alert'][] = 'alert:ldap_connect_failure';
- return false;
- }
-
- // Csatlakozás a szerverhez
- $r = @ldap_bind($ds, BACKEND_CONNECT_DN,BACKEND_CONNECT_PASSWORD);
-
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_bind_failure:ADSSearch';
- ldap_close($ds);
- return false;
- }
-
- // Keresés
- if (
- strpos(kisbetus($attr),'number') !== false
- && $attr != 'serialNumber'
- ) $filter = "(&$filter($attr=$pattern))";
- else $filter = "(&$filter($attr=*$pattern*))";
-
- $filter = "(&$filter($attr=*$pattern*))";
- $sr = @ldap_search($ds, $AUTH[$toPolicy]['adsBaseDn'], $filter, $searchAttrs);
- if (!$sr) {
- $_SESSION['alert'][] = "message:ldap_search_failure:".$filter;
- ldap_close($ds);
- return false;
- }
-
- $info = @ldap_get_entries($ds,$sr);
- ldap_close($ds);
-
- return $info;
-
- }
-
-######################################################
-# adsSearchAccount - felhasználó kereső függvény
-######################################################
-
- function adsSearchAccount($attr, $pattern, $searchAttrs = array('userCn'), $toPolicy = _POLICY) {
-
- global $accountAttrToADS;
-
- // A keresendő attribútum konvertálása ADS attribútummá
- if ($accountAttrToADS[ $attr ] != '') $attrADS = $accountAttrToADS[ $attr ];
- else $attrADS = $attr;
- if ($attrADS == 'dn') $attrADS = 'uid'; // dn-re nem megy a keresés!!
-
- // A lekérendő attribútumok konvertálása ADS attribútummá
- for ($i = 0; $i < count($searchAttrs); $i++) {
- if ($accountAttrToADS[ $searchAttrs[$i] ] != '') $searchAttrsADS[$i] = $accountAttrToADS[ $searchAttrs[$i] ];
- else $searchAttrsADS[$i] = $searchAttrs[$i];
- }
- $result = ADSSearch($attrADS, $pattern, $searchAttrsADS, '(&(objectclass=person)(!(objectclass=computer)))', $toPolicy);
- if ($result === false) {
- return false;
- } else {
-
- // ADS schema --> mayor schema konverzió
- for ($i = 0; $i < $result['count']; $i++) {
- // Egységes szerkezetre alakítjuk, azaz a dn is indexelt
- $result[$i]['dn'] = $return[$i]['userAccount'] = array('count' => 1, 0 => $result[$i]['dn']);
- for ($j = 0; $j < count($searchAttrs); $j++) {
- $a = $searchAttrs[$j];
- if (isset($result[$i][ kisbetus($accountAttrToADS[$a]) ])) {
- if ($accountAttrToADS[$a] != '') $return[$i][$a] = $result[$i][ kisbetus($accountAttrToADS[$a]) ];
- else $return[$i][$a] = $result[$i][$a];
- } else {
- $return[$i][$a] = array('count' => 0) ;
- }
- }
- $return[$i]['category'] = getAccountCategories($return[$i]['userAccount'][0], $toPolicy);
- $return[$i]['category']['count'] = count($return[$i]['category']);
- }
- $return['count'] = $result['count'];
-
- return $return;
-
- }
-
- }
-
-######################################################
-# adsSearchGroup - csoport kereső függvény
-######################################################
-
- function adsSearchGroup($attr, $pattern, $searchAttrs = array('groupCn, groupDesc'), $toPolicy = _POLICY) {
-
- global $groupAttrToADS;
-
- // A keresendő attribútum konvertálása ADS attribútummá
- if ($groupAttrToADS[ $attr ] != '') $attrADS = $groupAttrToADS[ $attr ];
- else $attrADS = $attr;
- if ($attrADS == 'dn') $attrADS = 'cn'; // dn-re nem megy a keresés!!
-
- // A lekérendő adtibútumok konvertálása ADS attribútummá
- for ($i = 0; $i < count($searchAttrs); $i++) {
- if ($groupAttrToADS[ $searchAttrs[$i] ] != '') $searchAttrsADS[$i] = $groupAttrToADS[ $searchAttrs[$i] ];
- else $searchAttrsADS[$i] = $searchAttrs[$i];
- }
-
- $result = ADSSearch($attrADS, $pattern, $searchAttrsADS, '(objectclass=group)', $toPolicy);
- if ($result === false) {
- return false;
- } else {
-
- // ADS schema --> mayor schema konverzió
- for ($i = 0; $i < $result['count']; $i++) {
- // Egységes szerkezetre alakítjuk, azaz a dn is indexelt
- $result[$i]['dn'] = $return[$i]['groupCn'] = array('count' => 1, 0 => $result[$i]['dn']);
- for ($j = 0; $j < count($searchAttrs); $j++) {
- $a = $searchAttrs[$j];
- if (!isset($groupAttrToADS[$a]) || $groupAttrToADS[$a] != '') {
- if (isset($result[$i][ $groupAttrToADS[$a] ])) $return[$i][$a] = $result[$i][ $groupAttrToADS[$a] ];
- else $return[$i][$a] = '';
- } else {
- $return[$i][$a] = $result[$i][$a];
- }
- }
- }
- $return['count'] = $result['count'];
-
- return $return;
-
- }
-
- }
-
-######################################################
-# adsDeleteAccount - account törlése
-######################################################
-
- function adsDeleteAccount($userAccount, $toPolicy = _POLICY) {
-
- global $AUTH;
-
- // $toPolicy --> ads backend - ellenőrzés
- if ($AUTH[$toPolicy]['backend'] != 'ads') {
- $_SESSION['alert'][] = 'page:wrong_backend:ads!='.$AUTH[$toPolicy]['backend'];
- return false;
- }
-
- $userDn = ADSuserAccountToDn($userAccount, $toPolicy);
- if ($userDn === false) return false;
-
- // Kapcsolódás az ADS szerverhez
- $ds = @ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- $_SESSION['alert'][] = 'alert:ldap_connect_failure';
- return false;
- }
-
- // Csatlakozás a szerverhez
- $r = @ldap_bind($ds, BACKEND_CONNECT_DN,BACKEND_CONNECT_PASSWORD);
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_bind_failure';
- ldap_close($ds);
- return false;
- }
-
- // Az uidNumber, a unixHomeDirectory lekerdezése
- $filter = "(&(objectclass=".$AUTH[$toPolicy]['adsUserObjectClass'].")(!(objectclass=computer)))";
- $justthese = array('uidNumber','unixHomedirectory');
- $sr = @ldap_search($ds,$userDn,$filter,$justthese);
- if (!$sr) {
- $_SESSION['alert'][] = "message:ldap_search_failure:".$userDn;
- ldap_close($ds);
- return false;
- } ;
-
- $info = @ldap_get_entries($ds,$sr);
- $uidNumber = $info[0]['uidnumber'][0];
- $homeDirectory = $info[0]['unixhomedirectory'][0];
- $uid=$userAccount;
-
- // user törlése
- if (!@ldap_delete($ds,$userDn)) {
- $_SESSION['alert'][] = 'message:ldap_delete_failure:user:'.$userAccount;
- }
-
- ldap_close($ds);
-
- /*
- Ha van megadva deleteAccountScript paraméter, akkor abba bejegyzi a törölt felhasználó adatait.
- A meghívott deleteAccount.sh nincs definiálva, testreszabható, megkötés egyedül a paraméter
- lista: userAccount, uidNumber, homeDirectory
- */
- if (defined('_DATADIR')
- && isset($AUTH[$toPolicy]['deleteAccountScript'])
- && file_exists(_DATADIR)
- ) {
- $sfp = fopen(_DATADIR.'/'.$AUTH[$toPolicy]['deleteAccountScript'],'a+');
- if ($sfp) {
- fwrite($sfp,"\n# $userAccount törlése: userAccount uidNumber homeDirectory\n");
- fwrite($sfp,"deleteAccount.sh '$userAccount' '$uidNumber' '$homeDirectory'\n");
- fclose($sfp);
- }
- }
-
- $_SESSION['alert'][] = 'info:delete_uid_success:'.$userDn;
- return true;
-
- }
-
-######################################################
-# adsDeleteGroup - account törlése
-######################################################
-
- function adsDeleteGroup($groupCn, $toPolicy = _POLICY) {
-
- global $AUTH;
-
- // $toPolicy --> ads backend - ellenőrzés
- if ($AUTH[$toPolicy]['backend'] != 'ads') {
- $_SESSION['alert'][] = 'page:wrong_backend:ads!='.$AUTH[$toPolicy]['backend'];
- return false;
- }
-
- $groupDn = ADSgroupCnToDn($groupCn, $toPolicy);
- if ($groupDn === false) return false;
-
- // Kapcsolódás az ADS szerverhez
- $ds = @ldap_connect($AUTH[$toPolicy]['adsHostname']);
- if (!$ds) {
- $_SESSION['alert'][] = 'alert:ldap_connect_failure';
- return false;
- }
-
- // Csatlakozás a szerverhez
- $r = @ldap_bind($ds, BACKEND_CONNECT_DN,BACKEND_CONNECT_PASSWORD);
- if (!$r) {
- $_SESSION['alert'][] = 'message:ldap_bind_failure';
- ldap_close($ds);
- return false;
- }
-
- if (!@ldap_delete($ds, $groupDn)) {
- $_SESSION['alert'][] = 'message:ldap_delete_failure:group:'.$groupCn;
- }
-
- ldap_close($ds);
-
- $_SESSION['alert'][] = 'info:delete_group_success:'.$groupCn;
- return true;
-
- }
-
-
-?>