function check_ad() { if(!CModule::IncludeModule('ldap')) return $this->Result(null, GetMessage("MAIN_SC_NO_LDAP_MODULE")); $rs = CLdapServer::GetList(); if (!$rs->Fetch()) return $this->Result(null, GetMessage("MAIN_SC_NO_LDAP_INTEGRATION")); return true; }
/** * * @param $ID * @return __CLDAPServerDBResult */ public static function GetByID($ID) { return CLdapServer::GetList(array(), $arFilter = array("ID" => IntVal($ID))); }
function NTLMAuth() { global $USER; if ($USER->IsAuthorized()) { return; } if (!array_key_exists("AUTH_TYPE", $_SERVER) || $_SERVER["AUTH_TYPE"] != "NTLM") { return; } $ntlm_varname = trim(COption::GetOptionString('ldap', 'ntlm_varname', 'REMOTE_USER')); if (array_key_exists($ntlm_varname, $_SERVER) && strlen($LOGIN = $_SERVER[$ntlm_varname]) > 0) { $DOMAIN = ""; if (($pos = strpos($LOGIN, "\\")) !== false) { $DOMAIN = substr($LOGIN, 0, $pos); $LOGIN = substr($LOGIN, $pos + 1); } $arFilterServer = array('ACTIVE' => 'Y'); if (strlen($DOMAIN) > 0) { $arFilterServer['CODE'] = $DOMAIN; } else { $DEF_DOMAIN_ID = intval(COption::GetOptionInt('ldap', 'ntlm_default_server', 0)); if ($DEF_DOMAIN_ID > 0) { $arFilterServer['ID'] = $DEF_DOMAIN_ID; } else { return; } } $db_ldap_serv = CLdapServer::GetList(array(), $arFilterServer); /*@var $xLDAP CLDAP*/ while ($xLDAP = $db_ldap_serv->GetNextServer()) { if ($xLDAP->Connect()) { if ($arLdapUser = $xLDAP->FindUser($LOGIN)) { $ID = $xLDAP->SetUser($arLdapUser); if ($ID > 0) { $USER->Authorize($ID); $xLDAP->Disconnect(); return; } } $xLDAP->Disconnect(); } } } }
break; case "activate": case "deactivate": $ld = new CLdapServer(); $arFields = array("ACTIVE" => $_REQUEST['action'] == "activate" ? "Y" : "N"); if (!$ld->Update($ID, $arFields)) { if ($e = $APPLICATION->GetException()) { $lAdmin->AddUpdateError(GetMessage("SAVE_ERROR") . $ID . ". " . $e->GetString(), $ID); } } break; } } } // initialise list - query data $rsData = CLdapServer::GetList(array($by => $order), $arFilter); $rsData = new CAdminResult($rsData, $sTableID); $rsData->NavStart(); // set up navigation string $lAdmin->NavText($rsData->GetNavPrint(GetMessage("LDAP_ADMIN_NAVSTRING"))); $arHeaders = array(); $arHeaders[] = array("id" => "ID", "content" => "ID", "default" => true, "sort" => "id"); $arHeaders[] = array("id" => "TIMESTAMP_X", "content" => GetMessage("LDAP_ADMIN_TSTAMP"), "default" => true, "sort" => "timestamp_x"); $arHeaders[] = array("id" => "NAME", "content" => GetMessage("LDAP_ADMIN_NAME"), "default" => true, "sort" => "name"); $arHeaders[] = array("id" => "ACTIVE", "content" => GetMessage("LDAP_ADMIN_ACT"), "default" => true, "sort" => "active"); $arHeaders[] = array("id" => "CONVERT_UTF8", "content" => "UTF-8", "default" => true, "sort" => "utf8"); $arHeaders[] = array("id" => "CODE", "content" => GetMessage("LDAP_ADMIN_CODE"), "default" => true, "sort" => "code"); $arHeaders[] = array("id" => "SERVER", "content" => GetMessage("LDAP_ADMIN_SERV"), "default" => true, "sort" => "server"); $arHeaders[] = array("id" => "SYNC", "content" => GetMessage("LDAP_ADMIN_SYNC"), "sort" => "sync"); $arHeaders[] = array("id" => "SYNC_PERIOD", "content" => GetMessage("LDAP_ADMIN_SYNC_PERIOD"), "sort" => "sync_period"); $arHeaders[] = array("id" => "SYNC_LAST", "content" => GetMessage("LDAP_ADMIN_SYNC_LAST"), "sort" => "sync_last");
echo GetMessage("USER_IMPORT_LDAP_SERVER"); ?> :</td> <td width="50%"> <select name="ldapServer" onChange="OnLdapSelect(this.selectedIndex - 1);"> <option value="0"><?php echo GetMessage("USER_IMPORT_SELECT_FROM_LIST"); ?> </option> <? $arAllFields = CLDAPUtil::GetSynFields(); // all user fields that are currently set up in the system $arFieldMaps = array(); $indSelected = -1; $i=-1; $dbLdap = CLdapServer::GetList(array("NAME" => "ASC"), array("ACTIVE" => "Y")); while ($arLdap = $dbLdap->GetNext()): $i++; $map = $arLdap["FIELD_MAP"]; foreach ($map as $user_f=>$ldap_f) { if (!array_key_exists($user_f,$arAllFields)) { unset($map[$user_f]); } } $arFieldMaps[] = $map; ?> <option value="<?php echo $arLdap["ID"]; ?>
############################################## # Bitrix: SiteManager # # Copyright (c) 2002-2012 Bitrix # # http://www.bitrixsoft.com # # mailto:admin@bitrixsoft.com # ############################################## global $MESS; include GetLangFileName($GLOBALS["DOCUMENT_ROOT"] . "/bitrix/modules/ldap/lang/", "/options.php"); IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/options.php"); $module_id = "ldap"; CModule::IncludeModule($module_id); $MOD_RIGHT = $APPLICATION->GetGroupRight($module_id); if ($MOD_RIGHT >= "R") { $arAllLdapServers = array(0 => GetMessage('LDAP_NOT_USE_DEFAULT_NTLM_SERVER')); $rsLdapServers = CLdapServer::GetList(); while ($arLdapServer = $rsLdapServers->Fetch()) { $arAllLdapServers[$arLdapServer['ID']] = $arLdapServer['NAME']; } // get current NTLM user login for displaying later if (!($ntlmVarname = $_POST['ntlm_varname'])) { $ntlmVarname = COption::GetOptionString($module_id, 'ntlm_varname', 'REMOTE_USER'); } if (array_key_exists($ntlmVarname, $_SERVER) && trim($_SERVER[$ntlmVarname]) != '') { $currentUserNTLMMsg = htmlspecialcharsbx($_SERVER[$ntlmVarname]); } else { $currentUserNTLMMsg = GetMessage("LDAP_CURRENT_USER_ABS"); } // set up form $arAllOptions = array(array("default_email", GetMessage('LDAP_OPTIONS_DEFAULT_EMAIL'), "no@email", array("text")), array("use_ntlm", GetMessage('LDAP_OPTIONS_USE_NTLM'), "N", array("checkbox")), array("use_ntlm_login", GetMessage('LDAP_CURRENT_USER'), $currentUserNTLMMsg, array("statictext")), array("ntlm_varname", GetMessage('LDAP_OPTIONS_NTLM_VARNAME'), "REMOTE_USER", array("text", 20)), array("ntlm_default_server", GetMessage('LDAP_DEFAULT_NTLM_SERVER'), "0", array("selectbox", $arAllLdapServers)), array("add_user_when_auth", GetMessage("LDAP_OPTIONS_NEW_USERS"), "Y", array("checkbox")), array("ntlm_auth_without_prefix", GetMessage("LDAP_WITHOUT_PREFIX"), "Y", array("checkbox")), GetMessage("LDAP_BITRIXVM_BLOCK"), array("bitrixvm_auth_support", GetMessage("LDAP_BITRIXVM_SUPPORT"), "N", array("checkbox")), array("bitrixvm_auth_net", GetMessage('LDAP_BITRIXVM_NET'), "", array("text", 40))); if ($MOD_RIGHT >= "W") {
function LDAPServerExists() { if (!function_exists("ldap_connect") || !CModule::IncludeModule("ldap")) { return false; } $rsData = CLdapServer::GetList(array(), array("ACTIVE" => "Y")); return $rsData->Fetch(); }