Esempio n. 1
0
        public void Deserialize(Runtime.Serialization.IO.CompactReader reader)
        {
            cacheIsRunning    = reader.ReadBoolean();
            cacheIsRegistered = reader.ReadBoolean();
            licenseIsExpired  = reader.ReadBoolean();

            name         = reader.ReadObject() as string;
            inproc       = reader.ReadBoolean();
            cacheType    = reader.ReadObject() as string;
            log          = reader.ReadObject() as Log;
            perfCounters = reader.ReadObject() as PerfCounters;

            indexes              = reader.ReadObject() as QueryIndex;
            backingSource        = reader.ReadObject() as BackingSource;
            notifications        = reader.ReadObject() as Notifications;
            cleanup              = reader.ReadObject() as Cleanup;
            storage              = reader.ReadObject() as Storage;
            evictionPolicy       = reader.ReadObject() as EvictionPolicy;
            expirationPolicy     = reader.ReadObject() as ExpirationPolicy;
            cluster              = reader.ReadObject() as Cluster;
            _replicationStrategy = reader.ReadObject() as ReplicationStrategy;

            autoBalancing            = reader.ReadObject() as AutoLoadBalancing;
            clientNodes              = reader.ReadObject() as ClientNodes;
            _sqlDependencyConfig     = reader.ReadObject() as SQLDependencyConfig;
            _taskConfiguration       = reader.ReadObject() as TaskConfiguration;
            deathDetection           = reader.ReadObject() as ClientDeathDetection;
            _runtimeContextValue     = reader.ReadObject() as string == "1" ? RtContextValue.JVCACHE : RtContextValue.NCACHE;
            _synchronizationStrategy = reader.ReadObject() as SynchronizationStrategy;

            string temp = reader.ReadObject() as String;

            _dataFormat = Common.Enum.DataFormat.Binary;
            clientActivityNotification = reader.ReadObject() as ClientActivityNotification;
        }
Esempio n. 2
0
        public void Deserialize(Runtime.Serialization.IO.CompactReader reader)
        {
            _cacheId           = reader.ReadObject() as string;
            _loadBalance       = reader.ReadBoolean();
            _isRegisteredLocal = reader.ReadBoolean();

            //Needs to be intinalized at every read
            _serversPriorityList = new Dictionary <int, CacheServer>();
            int lenght = reader.ReadInt32();

            for (int i = 0; i < lenght; i++)
            {
                _serversPriorityList.Add(reader.ReadInt32(), reader.ReadObject() as CacheServer);
            }

            _serverName           = reader.ReadObject() as string;
            _bindIp               = reader.ReadObject() as string;
            _serverRuntimeContext = reader.ReadObject() as string == "1" ? RtContextValue.JVCACHE : RtContextValue.NCACHE;

            if (reader.ReadBoolean())
            {
                _serverMapping = reader.ReadObject() as ServerMapping;
            }
            _enableClientLogs       = reader.ReadBoolean();
            _logLevel               = reader.ReadObject() as string;
            _enableServerPriorities = reader.ReadBoolean();
        }
Esempio n. 3
0
        private static string ExtractDomainName(string path, RtContextValue _context)
        {
            string domainName = "";

            string[] dcPath = path.Split(',');
            if (_context.Equals(RtContextValue.JVCACHE))
            {
                foreach (string str in dcPath)
                {
                    string[] keyvalue = str.Split('=');
                    if (keyvalue[0].ToLower() == "dc")
                    {
                        domainName += keyvalue[1];
                        domainName += ".";
                    }
                }
            }
            else
            {
                foreach (string str in dcPath)
                {
                    int index = str.IndexOf('=');
                    domainName += str.Substring(index + 1);
                    domainName += ".";
                }
            }
            domainName = domainName.Remove(domainName.Length - 1);
            return(domainName);
        }
Esempio n. 4
0
 public void Deserialize(Runtime.Serialization.IO.CompactReader reader)
 {
     cacheIsRunning    = reader.ReadBoolean();
     cacheIsRegistered = reader.ReadBoolean();
     licenseIsExpired  = reader.ReadBoolean();
     name                 = reader.ReadObject() as string;
     inproc               = reader.ReadBoolean();
     configID             = reader.ReadDouble();
     lastModified         = reader.ReadObject() as string;
     cacheType            = reader.ReadObject() as string;
     log                  = reader.ReadObject() as Log;
     perfCounters         = reader.ReadObject() as PerfCounters;
     autoBalancing        = reader.ReadObject() as AutoLoadBalancing;
     indexes              = reader.ReadObject() as QueryIndex;
     cleanup              = reader.ReadObject() as Cleanup;
     storage              = reader.ReadObject() as Storage;
     evictionPolicy       = reader.ReadObject() as EvictionPolicy;
     cluster              = reader.ReadObject() as Cluster;
     clientNodes          = reader.ReadObject() as ClientNodes;
     _runtimeContextValue = reader.ReadObject() as string == "1" ? RtContextValue.JVCACHE : RtContextValue.NCACHE;
 }
Esempio n. 5
0
        public void Deserialize(Runtime.Serialization.IO.CompactReader reader)
        {
            cacheIsRunning    = reader.ReadBoolean();
            cacheIsRegistered = reader.ReadBoolean();
            licenseIsExpired  = reader.ReadBoolean();
            name                     = reader.ReadObject() as string;
            inproc                   = reader.ReadBoolean();
            configID                 = reader.ReadString();
            configVersion            = reader.ReadDouble();
            lastModified             = reader.ReadObject() as string;
            cacheType                = reader.ReadObject() as string;
            log                      = reader.ReadObject() as Log;
            perfCounters             = reader.ReadObject() as PerfCounters;
            backingSource            = reader.ReadObject() as BackingSource;
            notifications            = reader.ReadObject() as Notifications;
            cleanup                  = reader.ReadObject() as Cleanup;
            storage                  = reader.ReadObject() as Storage;
            evictionPolicy           = reader.ReadObject() as EvictionPolicy;
            cluster                  = reader.ReadObject() as Cluster;
            _replicationStrategy     = reader.ReadObject() as ReplicationStrategy;
            security                 = reader.ReadObject() as Security;
            autoBalancing            = reader.ReadObject() as AutoLoadBalancing;
            clientNodes              = reader.ReadObject() as ClientNodes;
            _sqlDependencyConfig     = reader.ReadObject() as SQLDependencyConfig;
            deathDetection           = reader.ReadObject() as ClientDeathDetection;
            _runtimeContextValue     = reader.ReadObject() as string == "1" ? RtContextValue.JVCACHE : RtContextValue.NCACHE;
            _synchronizationStrategy = reader.ReadObject() as SynchronizationStrategy;
            string temp = reader.ReadObject() as String;

            if (temp.ToLower().Equals("binary"))
            {
                _dataFormat = Common.Enum.DataFormat.Binary;
            }
            else if (temp.ToLower().Equals("object"))
            {
                _dataFormat = Common.Enum.DataFormat.Object;
            }
            clientActivityNotification = reader.ReadObject() as ClientActivityNotification;
            depversion = (double)reader.ReadObject();
        }
Esempio n. 6
0
        public static void AddCache(string cacheId, int cachePort, RtContextValue serverRuntimeContext)
        {
            LoadXml();

            if (_configuration != null)
            {
                if (_configuration.CacheConfigurationsMap == null)
                {
                    _configuration.CacheConfigurationsMap = new Dictionary <string, CacheConfiguration>();
                }

                if (!_configuration.CacheConfigurationsMap.ContainsKey(cacheId.ToLower()))
                {
                    CacheConfiguration cacheConfiguration = new CacheConfiguration();
                    cacheConfiguration.CacheId = cacheId;
                    cacheConfiguration.ServerRuntimeContext = serverRuntimeContext;
                    cacheConfiguration.AddLocalServer();
                    _configuration.CacheConfigurationsMap[cacheId.ToLower()] = cacheConfiguration;
                }
            }
            SaveConfiguration();
        }
Esempio n. 7
0
        public static void UpdateServerNodes(string cacheId, Alachisoft.NCache.Management.ClientConfiguration.CacheServerList serversPriorityList, RtContextValue serverRuntimeContext)
        {
            LoadXml();

            if (_configuration != null)
            {
                if (_configuration.CacheConfigurationsMap == null)
                {
                    _configuration.CacheConfigurationsMap = new Dictionary <string, CacheConfiguration>();
                }

                cacheId = cacheId.ToLower();
                CacheConfiguration cacheConfiguration = null;

                if (_configuration.CacheConfigurationsMap.TryGetValue(cacheId, out cacheConfiguration))
                {
                    cacheConfiguration.ServersPriorityList = serversPriorityList.ServersList;
                }
                else
                {
                    cacheConfiguration         = new CacheConfiguration();
                    cacheConfiguration.CacheId = cacheId;
                    cacheConfiguration.BindIp  = bindIp;
                    cacheConfiguration.ServerRuntimeContext = serverRuntimeContext;
                    cacheConfiguration.ServersPriorityList  = serversPriorityList.ServersList;
                    _configuration.CacheConfigurationsMap.Add(cacheId, cacheConfiguration);
                }
            }

            SaveConfiguration();
        }
Esempio n. 8
0
        public void LoadConfiguration()
        {
            FileStream  fs = null;
            string      c_configFileName = null;
            XmlDocument configuration    = new XmlDocument();

            try
            {
                if (_cacheId == null)
                {
                    return;
                }
                c_configFileName = DirectoryUtil.GetBaseFilePath("client.ncconf", _search, out _result);
                if (c_configFileName == null)
                {
                    return;
                }
                FileInfo fileInfo = new FileInfo(c_configFileName);
                fs = fileInfo.OpenRead();
                configuration.Load(fs);
                fileInfo = null;

                bool serverPortFound = false;

                XmlNodeList serverPortList = configuration.GetElementsByTagName("ncache-server");
                if (serverPortList != null && serverPortList.Count > 0)
                {
                    XmlNode portNode = serverPortList.Item(0);
                    if (portNode != null)
                    {
                        XmlAttributeCollection attributes = portNode.Attributes;
                        if (attributes != null)
                        {
                            string currentAttrib = string.Empty;

                            if (initParam.ServerList != null && initParam.ServerList.Length > 0)
                            {
                                if (initParam.ServerList[0].Port > 0)
                                {
                                    _serverPort = initParam.ServerList[0].Port;
                                }
                            }
                            else
                            {
                                if (attributes["port"] != null)
                                {
                                    currentAttrib = attributes["port"].Value;
                                    if (currentAttrib != null)
                                    {
                                        _serverPort = Convert.ToInt32(currentAttrib);
                                    }
                                }
                            }
                        }
                        serverPortFound = true;
                    }
                }

                if (!serverPortFound)
                {
                    throw new Runtime.Exceptions.ConfigurationException("ncache-server missing in client confiugration");
                }

                XmlNodeList cacheList   = configuration.GetElementsByTagName("cache");
                XmlNodeList cacheConfig = null;

                for (int i = 0; i < cacheList.Count; i++)
                {
                    XmlNode cache = cacheList.Item(i);
                    if (cache.Attributes.GetNamedItem("id").Value.ToLower().Equals(_cacheId.ToLower()))
                    {
                        if (cache.Attributes["load-balance"] != null)
                        {
                            this._balanceNodes = Convert.ToBoolean(cache.Attributes["load-balance"].Value);
                        }
                        if (initParam != null && initParam.IsSet(LOADBALANCE))
                        {
                            this._balanceNodes = initParam.LoadBalance;
                        }



                        try
                        {
                            if (cache.Attributes["enable-client-logs"] != null)
                            {
                                this._enableClientLogs = Convert.ToBoolean(cache.Attributes["enable-client-logs"].Value.ToString());
                            }
                        }
                        catch (Exception)
                        { }

                        if (cache.Attributes["log-level"] != null)
                        {
                            this._enableDetailedClientLogs = cache.Attributes["log-level"].Value.ToString().ToLower() == "info" ? true : false;
                        }

                        this.serverRuntimeContext = RtContextValue.NCACHE;
                        _importHashmap            = true;

                        cacheConfig = cache.ChildNodes;
                        break;
                    }
                }

                if (cacheConfig == null)
                {
                    if (!String.IsNullOrEmpty(_cacheId))
                    {
                        if (_result != Search.GlobalSearch)
                        {
                            _search = _result + 1;
                            LoadConfiguration();
                        }
                    }
                    return;
                }
                _search = _result;
                LoadRemoteServerMappingConfig(cacheConfig);

                LoadRemoteServerConfig(cacheConfig);
            }
            catch (Runtime.Exceptions.ConfigurationException)
            {
                throw;
            }
            catch (System.IO.IOException) { throw; }
            catch (Exception e)
            {
                throw new Runtime.Exceptions.ConfigurationException("An error occured while reading client.ncconf. " + e.Message);
            }

            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }
Esempio n. 9
0
        public void LoadConfiguration()
        {
            FileStream  fs = null;
            string      c_configFileName = null;
            XmlDocument configuration    = new XmlDocument();

            try
            {
                if (_cacheId == null)
                {
                    return;
                }

                c_configFileName = DirectoryUtil.GetBaseFilePath("client.ncconf", _search, out _result);


                if (c_configFileName == null)
                {
                    return;
                }

                FileInfo fileInfo = new FileInfo(c_configFileName);
                fs = fileInfo.OpenRead();
                configuration.Load(fs);
                fileInfo = null;

                bool serverPortFound = false;


                XmlNodeList serverPortList = configuration.GetElementsByTagName("ncache-server");
                CultureInfo cultureInfo    = Thread.CurrentThread.CurrentCulture;
                try
                {
                    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                    if (serverPortList != null && serverPortList.Count > 0)
                    {
                        XmlNode portNode = serverPortList.Item(0);
                        if (portNode != null)
                        {
                            XmlAttributeCollection attributes = portNode.Attributes;
                            if (attributes != null)
                            {
                                if (attributes["port"] != null && attributes["port"].Value != null)
                                {
                                    try
                                    {
                                        _serverPortFromConfig = Convert.ToInt32(attributes["port"].Value);
                                    }
                                    catch (Exception)
                                    { }
                                }


                                if (initParam != null && initParam.IsSet(PORT))
                                {
                                    _serverPort = initParam.Port;
                                }
                                else
                                {
                                    _serverPort = _serverPortFromConfig;
                                }

                                if (initParam != null && initParam.IsSet(OPTIMEOUT))
                                {
                                    _timeout = initParam.ClientRequestTimeOut * 1000;
                                }
                                else
                                {
                                    if (attributes["client-request-timeout"] != null && attributes["client-request-timeout"].Value != null)
                                    {
                                        try
                                        {
                                            _timeout = Convert.ToInt32(attributes["client-request-timeout"].Value) * 1000;
                                        }
                                        catch (Exception) { }
                                    }
                                }

                                if (initParam != null && initParam.IsSet(CONNECTIONRETRIES))
                                {
                                    _retries = initParam.ConnectionRetries;
                                }
                                else
                                {
                                    if (attributes["connection-retries"] != null && attributes["connection-retries"].Value != null)
                                    {
                                        try { _retries = Convert.ToInt32(attributes["connection-retries"].Value); }
                                        catch { }
                                    }
                                }

                                if (initParam != null && initParam.IsSet(RETRYINTERVAL))
                                {
                                    _retrySleep = initParam.RetryInterval * 1000; //: RetryInterval Property returns value/1000
                                }
                                else
                                {
                                    if (attributes["retry-interval"] != null && attributes["retry-interval"].Value != null)
                                    {
                                        try
                                        {
                                            _retrySleep = Convert.ToInt32(attributes["retry-interval"].Value) * 1000;
                                        }
                                        catch (Exception)
                                        {
                                        }
                                    }
                                }

                                if (initParam != null && initParam.IsSet(CONNECTIONTIMEOUT))
                                {
                                    _connectionTimeout = initParam.ConnectionTimeout * 1000;
                                }
                                else
                                {
                                    if (attributes["connection-timeout"] != null && attributes["connection-timeout"].Value != null)
                                    {
                                        try
                                        {
                                            _connectionTimeout = Convert.ToInt32(attributes["connection-timeout"].Value) * 1000;
                                        }
                                        catch (Exception)
                                        { }
                                    }
                                }


                                if (initParam != null && initParam.IsSet(RETRYCONNECTIONDELAY))
                                {
                                    _retryConnectionDelay = initParam.RetryConnectionDelay * 1000;
                                }
                                else
                                {
                                    if (attributes["retry-connection-delay"] != null && attributes["retry-connection-delay"].Value != null)
                                    {
                                        try
                                        {
                                            _retryConnectionDelay = Convert.ToInt32(attributes["retry-connection-delay"].Value) * 1000;
                                        }
                                        catch (Exception)
                                        { }
                                    }
                                }
                            }

                            serverPortFound = true;
                        }
                    }

                    if (!serverPortFound)
                    {
                        throw new Runtime.Exceptions.ConfigurationException(
                                  "ncache-server missing in client confiugration");
                    }


                    XmlNodeList cacheList   = configuration.GetElementsByTagName("cache");
                    XmlNodeList cacheConfig = null;

                    for (int i = 0; i < cacheList.Count; i++)
                    {
                        XmlNode cache = cacheList.Item(i);
                        if (cache.Attributes.GetNamedItem("id").Value.ToLower().Equals(_cacheId.ToLower()))
                        {
                            if (cache.Attributes["load-balance"] != null)
                            {
                                this._balanceNodes = Convert.ToBoolean(cache.Attributes["load-balance"].Value);
                            }

                            if (initParam != null && initParam.IsSet(LOADBALANCE))
                            {
                                this._balanceNodes = initParam.LoadBalance;
                            }

                            if (cache.Attributes["default-readthru-provider"] != null)
                            {
                                this._defaultReadThruProvider =
                                    cache.Attributes["default-readthru-provider"].Value.ToString();
                            }

                            if (initParam != null && initParam.IsSet(DEFAULTREADTHRUPROVIDER))
                            {
                                this._defaultReadThruProvider = initParam.DefaultReadThruProvider;
                            }

                            if (cache.Attributes["default-writethru-provider"] != null)
                            {
                                this._defaultWriteThruProvider =
                                    cache.Attributes["default-writethru-provider"].Value.ToString();
                            }

                            if (initParam != null && initParam.IsSet(DEFAULTWRITETHRUPROVIDER))
                            {
                                this._defaultWriteThruProvider = initParam.DefaultWriteThruProvider;
                            }


                            try
                            {
                                if (cache.Attributes["enable-client-logs"] != null)
                                {
                                    this._enableClientLogs =
                                        Convert.ToBoolean(cache.Attributes["enable-client-logs"].Value.ToString());
                                }
                            }
                            catch (Exception)
                            {
                            }

                            if (cache.Attributes["log-level"] != null)
                            {
                                this._enableDetailedClientLogs =
                                    cache.Attributes["log-level"].Value.ToString().ToLower() == "info" ? true : false;
                            }


                            this.serverRuntimeContext = RtContextValue.NCACHE;

                            _importHashmap = true;

                            cacheConfig = cache.ChildNodes;
                            break;
                        }
                    }

                    if (cacheConfig == null)
                    {
                        if (!String.IsNullOrEmpty(_cacheId))
                        {
                            if (_result != Search.GlobalSearch)
                            {
                                _search = _result + 1;
                                LoadConfiguration();
                            }
                        }

                        return;
                    }

                    _search = _result;
                    LoadRemoteServerMappingConfig(cacheConfig);


                    LoadRemoteServerConfig(cacheConfig);
                }
                finally
                {
                    System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo;
                }
            }

            catch (Runtime.Exceptions.ConfigurationException)
            {
                throw;
            }
            catch (System.IO.IOException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new Runtime.Exceptions.ConfigurationException(
                          "An error occurred while reading client.ncconf. " + e.Message);
            }

            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }
Esempio n. 10
0
 public void Deserialize(Runtime.Serialization.IO.CompactReader reader)
 {
     name   = reader.ReadObject() as string;
     Status = (ClientNodeStatus)reader.ReadInt32();
     clientRuntimeContext = reader.ReadObject() as string == "1" ? RtContextValue.JVCACHE : RtContextValue.NCACHE;
 }
Esempio n. 11
0
        public static string GetDomainName(string domainController, string port, string userName, string password, RtContextValue _context)
        {
            string _domainName = "";

            if (_context.Equals(RtContextValue.JVCACHE))
            {
                int ldapPort = ConvertPort(port);
                if (ldapPort == 0)
                {
                    ldapPort = 389;
                }
                _ldapConnection = _ldapConnection = GetLdapConnection(domainController, ldapPort, userName, password);

                try
                {
                    _ldapConnection.Bind();
                    _domainName = domainController;
                }
                catch (LdapException ex)
                {
                    throw ex;
                }
            }
            else
            {
                #region -----Previous code-----
                DirectoryEntry    adRoot   = new DirectoryEntry("LDAP://" + domainController, userName, password);
                DirectorySearcher searcher = new DirectorySearcher(adRoot);
                try
                {
                    SearchResult result = searcher.FindOne();
                    _domainName = ExtractDomainName(result.Path, _context);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    adRoot.Dispose();
                    searcher.Dispose();
                }

                #endregion
            }
            return(_domainName);
        }
Esempio n. 12
0
        public void Deserialize(Runtime.Serialization.IO.CompactReader reader)
        {
            _cacheId = reader.ReadObject() as string;
            _loadBalance = reader.ReadBoolean();
            _isRegisteredLocal = reader.ReadBoolean();
            
            //Needs to be intinalized at every read
            _serversPriorityList = new Dictionary<int, CacheServer>();
            int lenght = reader.ReadInt32();
            for (int i = 0; i < lenght; i++)
            {
                _serversPriorityList.Add(reader.ReadInt32(), reader.ReadObject() as CacheServer);
            }
            
            _serverName = reader.ReadObject() as string;
            _bindIp = reader.ReadObject() as string;
            _serverRuntimeContext = reader.ReadObject() as string == "1" ? RtContextValue.JVCACHE : RtContextValue.NCACHE;
  
            if (reader.ReadBoolean())
            {
                _serverMapping = reader.ReadObject() as ServerMapping;
            }
            _enableClientLogs = reader.ReadBoolean();
            _logLevel = reader.ReadObject() as string;
            _enableServerPriorities = reader.ReadBoolean();

        }
Esempio n. 13
0
 public new void Deserialize(Runtime.Serialization.IO.CompactReader reader)
 {
     _clientId      = reader.ReadObject() as string;
     _clientContext = reader.ReadObject() as string == "1" ? RtContextValue.JVCACHE : RtContextValue.NCACHE;
     base.Deserialize(reader);
 }
Esempio n. 14
0
        public static DomainInfo GetDomainInfo(string domainController, string port, string userName, string password, string searchBase, RtContextValue _context)
        {
            int ldapPort = ConvertPort(port);

            if (ldapPort == 0)
            {
                ldapPort = 389;
            }
            DomainInfo domainInfo = new DomainInfo();

            if (domains != null && domains.Contains(domainController))
            {
                domainInfo.DomainName      = domainController;
                domainInfo.Users           = (ArrayList)domains[domainController];
                domainInfo.DistiguishNames = (Hashtable)domains[domainController + "1"];
                return(domainInfo);
            }

            if (domains == null)
            {
                domains = new Hashtable();
            }
            ArrayList users = new ArrayList();

            if (_context.Equals(RtContextValue.JVCACHE))
            {
                Hashtable distinguishNames = new Hashtable();

                //Connection Build for Ldap Authentication
                _ldapConnection = GetLdapConnection(domainController, ldapPort, userName, password);

                string filter = "(objectClass=*)";

                String[] attribsToReturn;

                string attribs = "cn";

                // split the single string expression from the string argument into an array of strings
                attribsToReturn = attribs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                SearchRequest searchRequest = new SearchRequest(searchBase, filter, System.DirectoryServices.Protocols.SearchScope.Subtree, attribsToReturn);
                try
                {
                    SearchResponse searchResponse = (SearchResponse)_ldapConnection.SendRequest(searchRequest);

                    if (searchResponse.Entries.Count > 0)
                    {
                        foreach (SearchResultEntry entry in searchResponse.Entries)
                        {
                            // retrieve a specific attribute
                            SearchResultAttributeCollection attributes = entry.Attributes;
                            foreach (DirectoryAttribute attribute in attributes.Values)
                            {
                                users.Add(attribute[0].ToString());
                                distinguishNames.Add(attribute[0].ToString(), entry.DistinguishedName);
                            }
                        }
                    }
                }
                catch (Exception ex) { throw ex; }

                domainInfo.Users           = users;
                domainInfo.DistiguishNames = distinguishNames;

                domains[domainController]       = users;
                domains[domainController + "1"] = distinguishNames;
            }
            else
            {
                #region --- Previous Code ----
                DirectoryEntry    adRoot   = new DirectoryEntry("LDAP://" + domainController, userName, password);
                DirectorySearcher searcher = new DirectorySearcher(adRoot);
                searcher.SearchScope     = System.DirectoryServices.SearchScope.Subtree;
                searcher.ReferralChasing = ReferralChasingOption.All;
                searcher.Filter          = "(&(objectClass=user)(objectCategory=person))";
                searcher.PropertiesToLoad.Add("SAMAccountname");
                searcher.PageSize = 1000;

                try
                {
                    SearchResultCollection result = searcher.FindAll();
                    foreach (SearchResult a in result)
                    {
                        DirectoryEntry entry    = a.GetDirectoryEntry();
                        string         UserName = a.Properties["SAMAccountname"][0].ToString();
                        users.Add(UserName);
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    adRoot.Dispose();
                    searcher.Dispose();
                }
                domainInfo.Users = users;

                domains[domainController] = users;
                #endregion
            }
            return(domainInfo);
        }
Esempio n. 15
0
        public void Deserialize(Runtime.Serialization.IO.CompactReader reader)
        {           
            cacheIsRunning=  reader.ReadBoolean();
            cacheIsRegistered = reader.ReadBoolean();
            licenseIsExpired = reader.ReadBoolean();
            name = reader.ReadObject() as string;
            inproc = reader.ReadBoolean();
            configID = reader.ReadDouble();
            lastModified = reader.ReadObject() as string;
            cacheType = reader.ReadObject() as string;
            log = reader.ReadObject() as Log;
            perfCounters = reader.ReadObject() as PerfCounters;
            autoBalancing = reader.ReadObject() as AutoLoadBalancing;
            indexes = reader.ReadObject() as QueryIndex;
            cleanup = reader.ReadObject() as Cleanup;
            storage = reader.ReadObject() as Storage;
            evictionPolicy = reader.ReadObject() as EvictionPolicy;
            cluster = reader.ReadObject() as Cluster;            
            clientNodes = reader.ReadObject() as ClientNodes;
            _runtimeContextValue = reader.ReadObject() as string == "1" ? RtContextValue.JVCACHE : RtContextValue.NCACHE;

        }
Esempio n. 16
0
        public void LoadConfiguration()
        {

            FileStream fs = null;
            string c_configFileName = null;
            XmlDocument configuration = new XmlDocument();
            
            try
            {
                if (_cacheId == null) return;
                c_configFileName = DirectoryUtil.GetBaseFilePath("client.ncconf",_search,out _result);
                if (c_configFileName == null)
                {
                    return;
                }
                FileInfo fileInfo = new FileInfo(c_configFileName);
                fs = fileInfo.OpenRead();
                configuration.Load(fs);
                fileInfo = null;
  
                bool serverPortFound = false;

                XmlNodeList serverPortList = configuration.GetElementsByTagName("ncache-server");
                if (serverPortList != null && serverPortList.Count > 0)
                {
                    XmlNode portNode = serverPortList.Item(0);
                    if (portNode != null)
                    {
                        XmlAttributeCollection attributes = portNode.Attributes;
                        if (attributes != null)
                        {
                            string currentAttrib = string.Empty;

                            if (initParam.ServerList !=null && initParam.ServerList.Length > 0)
                            {
                                if(initParam.ServerList[0].Port > 0)
                                    _serverPort = initParam.ServerList[0].Port;
                            }
                            else
                            {
                                if (attributes["port"] != null)
                                {
                                    currentAttrib = attributes["port"].Value;
                                    if (currentAttrib != null)
                                    {
                                        _serverPort = Convert.ToInt32(currentAttrib);
                                    }
                                }
                            }
                        }
                        serverPortFound = true;
                    }
                }

                if (!serverPortFound)
                    throw new Runtime.Exceptions.ConfigurationException("ncache-server missing in client confiugration");

                XmlNodeList cacheList = configuration.GetElementsByTagName("cache");
                XmlNodeList cacheConfig = null;

                for (int i = 0; i < cacheList.Count; i++)
                {
                    XmlNode cache = cacheList.Item(i);
                    if (cache.Attributes.GetNamedItem("id").Value.ToLower().Equals(_cacheId.ToLower()))
                    {

                        if (cache.Attributes["load-balance"] != null)
                        {
                            this._balanceNodes = Convert.ToBoolean(cache.Attributes["load-balance"].Value);
                        }
                        if (initParam != null && initParam.IsSet(LOADBALANCE))
                        {
                            this._balanceNodes = initParam.LoadBalance;
                        }



                      try
                        {
                            if (cache.Attributes["enable-client-logs"] != null)
                                this._enableClientLogs = Convert.ToBoolean(cache.Attributes["enable-client-logs"].Value.ToString());
                        }
                        catch (Exception)
                        { }

                        if(cache.Attributes["log-level"] != null)
                            this._enableDetailedClientLogs = cache.Attributes["log-level"].Value.ToString().ToLower() == "info" ? true : false;
                        
                        this.serverRuntimeContext = RtContextValue.NCACHE;
                        _importHashmap = true;

                        cacheConfig = cache.ChildNodes;
                        break;
                    }
                }

                if (cacheConfig == null)
                {
                    if (!String.IsNullOrEmpty(_cacheId))
                    {
                        if (_result != Search.GlobalSearch)
                        {
                            _search = _result + 1;
                            LoadConfiguration();
                        }
                    }
                    return;
                }
                _search = _result;
                LoadRemoteServerMappingConfig(cacheConfig);

                LoadRemoteServerConfig(cacheConfig);
            }
            catch (Runtime.Exceptions.ConfigurationException)
            {
                throw;
            }
            catch (System.IO.IOException) { throw; }
            catch (Exception e)
            {
                throw new Runtime.Exceptions.ConfigurationException("An error occured while reading client.ncconf. " + e.Message);

            }

            finally
            {
                if (fs != null) fs.Close();
            }
        }
Esempio n. 17
0
 public void Deserialize(Runtime.Serialization.IO.CompactReader reader)
 {
     name = reader.ReadObject() as string;
     Status = (ClientNodeStatus)reader.ReadInt32();
     clientRuntimeContext = reader.ReadObject() as string == "1" ? RtContextValue.JVCACHE : RtContextValue.NCACHE;
 }
Esempio n. 18
0
        public static void AddCache(string cacheId, RtContextValue serverRuntimeContext)
        {
            LoadXml();

            if (_configuration != null)
            {
                if (_configuration.CacheConfigurationsMap == null)
                    _configuration.CacheConfigurationsMap = new Dictionary<string, CacheConfiguration>();

                if (!_configuration.CacheConfigurationsMap.ContainsKey(cacheId.ToLower()))
                {
                    CacheConfiguration cacheConfiguration = new CacheConfiguration();
                    cacheConfiguration.CacheId = cacheId;
                    cacheConfiguration.ServerRuntimeContext = serverRuntimeContext;
                    cacheConfiguration.AddLocalServer();
                    _configuration.CacheConfigurationsMap[cacheId.ToLower()] = cacheConfiguration;
                }
            }

            SaveConfiguration();
        }
Esempio n. 19
0
        public static void UpdateServerNodes(string cacheId, Alachisoft.NCache.Management.ClientConfiguration.CacheServerList serversPriorityList, RtContextValue serverRuntimeContext)
        {
            LoadXml();

            if (_configuration != null)
            {
                if (_configuration.CacheConfigurationsMap == null)
                    _configuration.CacheConfigurationsMap = new Dictionary<string, CacheConfiguration>();

                cacheId = cacheId.ToLower();
                CacheConfiguration cacheConfiguration = null;

                if (!_configuration.CacheConfigurationsMap.TryGetValue(cacheId, out cacheConfiguration))
                {
                    cacheConfiguration = new CacheConfiguration();
                    cacheConfiguration.CacheId = cacheId;
                    cacheConfiguration.BindIp = bindIp;
                    cacheConfiguration.ServerRuntimeContext = serverRuntimeContext;
                    _configuration.CacheConfigurationsMap.Add(cacheId, cacheConfiguration);
                }

               

                cacheConfiguration.ServersPriorityList = serversPriorityList.ServersList;
            }

            SaveConfiguration();
        }