public function refreshFakeData() { // debug("refreshFakeData sid=". $this->sid); $test_data = variable_get('ldap_test_server__' . $this->sid, array()); $this->methodResponses = is_array($test_data) && isset($test_data['methodResponses']) ? $test_data['methodResponses'] : array(); $this->entries = is_array($test_data) && isset($test_data['ldap']) ? $test_data['ldap'] : array(); // debug('this->entries');debug($this->entries); $this->searchResults = isset($test_data['search_results']) ? $test_data['search_results'] : array(); $this->detailedWatchdogLog = variable_get('ldap_help_watchdog_detail', 0); foreach ($test_data['properties'] as $property_name => $property_value) { $this->{$property_name} = $property_value; } // $this->basedn = unserialize($this->basedn); if (isset($test_data['bindpw']) && $test_data['bindpw'] != '') { $this->bindpw = ldap_servers_decrypt($this->bindpw); } }
/** * Constructor Method * * can take array of form property_name => property_value * or $sid, where sid is used to derive the include file. */ function __construct($sid) { if (!is_scalar($sid)) { $test_data = $sid; } else { $test_data = variable_get('ldap_test_server__' . $sid, array()); } $this->sid = $sid; $this->methodResponses = $test_data['methodResponses']; $this->testUsers = $test_data['users']; $this->testGroups = is_array($test_data) && isset($test_data['groups']) ? $test_data['groups'] : array(); $this->searchResults = isset($test_data['search_results']) ? $test_data['search_results'] : array(); $this->detailedWatchdogLog = variable_get('ldap_help_watchdog_detail', 0); foreach ($test_data['properties'] as $property_name => $property_value) { $this->{$property_name} = $property_value; } if (is_scalar($this->basedn)) { $this->basedn = unserialize($this->basedn); } if (isset($server_record['bindpw']) && $server_record['bindpw'] != '') { $this->bindpw = ldap_servers_decrypt($this->bindpw); } }
/** * this method sets properties that don't directly map from db record. it is split out so it can be shared with ldapServerTest.class.php */ protected function initDerivedProperties($bindpw) { // get this->basedn in array format if (!$this->basedn) { $this->basedn = array(); } elseif (is_array($this->basedn)) { // do nothing } else { $basedn_unserialized = @unserialize($this->basedn); if (is_array($basedn_unserialized)) { $this->basedn = $basedn_unserialized; } else { $this->basedn = array(); $token = is_scalar($basedn_unserialized) ? $basedn_unserialized : print_r($basedn_unserialized, TRUE); debug("basednb desearialization error" . $token); watchdog('ldap_server', 'Failed to deserialize LdapServer::basedn of !basedn', array('!basedn' => $token), WATCHDOG_ERROR); } } if ($this->followrefs && !function_exists('ldap_set_rebind_proc')) { $this->followrefs = FALSE; } if ($bindpw) { $this->bindpw = ldap_servers_decrypt($bindpw); } $this->paginationEnabled = (bool) (ldap_servers_php_supports_pagination() && $this->searchPagination); $this->queriableWithoutUserCredentials = (bool) ($this->bind_method == LDAP_SERVERS_BIND_METHOD_SERVICE_ACCT || $this->bind_method == LDAP_SERVERS_BIND_METHOD_ANON_USER); $this->editPath = !$this->sid ? '' : 'admin/config/people/ldap/servers/edit/' . $this->sid; $this->groupGroupEntryMembershipsConfigured = $this->groupMembershipsAttrMatchingUserAttr && $this->groupMembershipsAttr; $this->groupUserMembershipsConfigured = $this->groupUserMembershipsAttrExists && $this->groupUserMembershipsAttr; }
/** * this method sets properties that don't directly map from db record */ protected function initDerivedProperties($bindpw) { // debug('initDerivedProperties'); debug($this->basedn); if (!is_array($this->basedn)) { $basedn_unserialized = @unserialize($this->basedn); // debug('basedn_unserialized'); debug($basedn_unserialized); $this->basedn = $basedn_unserialized; } // debug('initDerivedProperties'); debug($this->basedn); if ($bindpw != '') { $this->bindpw = ldap_servers_decrypt($bindpw); } $this->paginationEnabled = (bool) (ldap_servers_php_supports_pagination() && $this->searchPagination); $this->queriableWithoutUserCredentials = (bool) ($this->bind_method == LDAP_SERVERS_BIND_METHOD_SERVICE_ACCT || $this->bind_method == LDAP_SERVERS_BIND_METHOD_ANON_USER); $this->editPath = 'admin/config/people/ldap/servers/edit/' . $this->sid; $this->groupGroupEntryMembershipsConfigured = $this->groupMembershipsAttrMatchingUserAttr && $this->groupMembershipsAttr; $this->groupUserMembershipsConfigured = $this->groupUserMembershipsAttrExists && $this->groupUserMembershipsAttr; }
/** * Constructor Method */ function __construct($sid) { if (!is_scalar($sid)) { return; } $this->detailed_watchdog_log = variable_get('ldap_help_watchdog_detail', 0); $server_record = array(); if (module_exists('ctools')) { ctools_include('export'); $result = ctools_export_load_object('ldap_servers', 'names', array($sid)); if (isset($result[$sid])) { $server_record[$sid] = $result[$sid]; foreach ($server_record[$sid] as $property => $value) { $this->{$property} = $value; } } } else { $select = db_select('ldap_servers')->fields('ldap_servers')->condition('ldap_servers.sid', $sid)->execute(); foreach ($select as $record) { $server_record[$record->sid] = $record; } } if (!isset($server_record[$sid])) { $this->inDatabase = FALSE; return; } $server_record = $server_record[$sid]; if ($server_record) { $this->inDatabase = TRUE; $this->sid = $sid; $this->detailedWatchdogLog = variable_get('ldap_help_watchdog_detail', 0); } else { // @todo throw error } foreach ($this->field_to_properties_map() as $db_field_name => $property_name) { if (isset($server_record->{$db_field_name})) { $this->{$property_name} = $server_record->{$db_field_name}; } } if (is_scalar($this->basedn)) { $this->basedn = unserialize($this->basedn); } if (isset($server_record->bindpw) && $server_record->bindpw != '') { $this->bindpw = $server_record->bindpw; $this->bindpw = ldap_servers_decrypt($this->bindpw); } $this->paginationEnabled = (bool) (ldap_servers_php_supports_pagination() && $this->searchPagination); $this->queriableWithoutUserCredentials = (bool) ($this->bind_method == LDAP_SERVERS_BIND_METHOD_SERVICE_ACCT || $this->bind_method == LDAP_SERVERS_BIND_METHOD_ANON_USER); $this->editPath = 'admin/config/people/ldap/servers/edit/' . $this->sid; }