load correct domain even if Samba version differs

This commit is contained in:
Roland Gruber 2003-09-21 14:59:28 +00:00
parent 8675e6a9cb
commit 76888028de
1 changed files with 42 additions and 18 deletions

View File

@ -48,7 +48,6 @@ function getUserProfiles() {
// returns an array of String with all available group profiles (without .prg) // returns an array of String with all available group profiles (without .prg)
function getGroupProfiles() { function getGroupProfiles() {
// group profiles are not supported at this time
$dir = @dir(substr(__FILE__, 0, strlen(__FILE__) - 17) . "/config/profiles/groups"); $dir = @dir(substr(__FILE__, 0, strlen(__FILE__) - 17) . "/config/profiles/groups");
$ret = array(); $ret = array();
$pos = 0; $pos = 0;
@ -180,6 +179,18 @@ function loadUserProfile($profile) {
if (substr($line, 0, 12) == "smb_domain: ") { if (substr($line, 0, 12) == "smb_domain: ") {
if ($_SESSION['config']->is_samba3()) { if ($_SESSION['config']->is_samba3()) {
$dn = chop(substr($line, 12, strlen($line)-12)); $dn = chop(substr($line, 12, strlen($line)-12));
if (! stristr($dn, "sambaDomainName=")) { // Samba 3 and Samba 2 profile
// get domain list
$doms = $_SESSION['ldap']->search_domains($_SESSION['config']->get_domainSuffix());
// search domain name
for ($d = 0; $d < sizeof($doms); $d++) {
if (strtolower($doms[$d]->name) == strtolower($dn)) {
$acc->smb_domain = $doms[$d];
break;
}
}
}
else { // Samba 3 and Samba 3 profile
// load domain object // load domain object
$dom = new samba3domain(); $dom = new samba3domain();
$sr = @ldap_search($_SESSION['ldap']->server, $dn, "objectClass=sambaDomain"); $sr = @ldap_search($_SESSION['ldap']->server, $dn, "objectClass=sambaDomain");
@ -199,7 +210,20 @@ function loadUserProfile($profile) {
} }
$acc->smb_domain = $dom; $acc->smb_domain = $dom;
} }
else $acc->smb_domain = chop(substr($line, 12, strlen($line)-12)); }
else {
$dom_name = chop(substr($line, 12, strlen($line)-12));
if (substr($dom_name, 0, 16) == "sambaDomainName=") { // Samba 2 and Samba 3 profile
// extract domain name from DN
$dom_name = substr($dom_name, 16, strlen($dom_name) - 16);
$pos = strpos($dom_name, ",");
$dom_name = substr($dom_name, 0, $pos);
$acc->smb_domain = $dom_name;
}
else { // Samba 2 and Samba 2 profile
$acc->smb_domain = $dom_name;
}
}
continue; continue;
} }
if (substr($line, 0, 7) == "quota: ") { if (substr($line, 0, 7) == "quota: ") {