Example #1
0
        /// <summary>
        /// Set the iFolder LDAP Settings
        /// </summary>
        /// <param name="settings">The LdapSettings Object</param>
        public static void SetSettings(LdapSettings settings)
        {
            Ldap.LdapSettings ldap = Ldap.LdapSettings.Get(Store.StorePath);

            // host
            ldap.Host = settings.LdapHost;

            // secure
            ldap.SSL = bool.Parse(settings.LdapSecure.ToLower());

            // port
            ldap.Port = int.Parse(settings.LdapPort);

            // DN
            ldap.ProxyDN = settings.ProxyDN;

            // context
            ldap.SearchContexts = settings.SearchContexts;

            // interval
            ldap.SyncInterval = int.Parse(settings.SyncInterval);

            // sync on start
            ldap.SyncOnStart = bool.Parse(settings.SyncOnStart.ToLower());

            // save changes
            ldap.Commit();

            //Set the password in the store, not the config file. The ldap sync removes it from the config
            Simias.Enterprise.Common.ProxyUser user = new Simias.Enterprise.Common.ProxyUser();
            user.Password = settings.ProxyPassword;
        }
Example #2
0
        /// <summary>
        /// Get the iFolder LDAP Settings
        /// </summary>
        /// <returns>An LdapSettings Object</returns>
        public static LdapSettings GetSettings()
        {
            LdapSettings settings = new LdapSettings();

            Ldap.LdapSettings ldap = Ldap.LdapSettings.Get(Store.StorePath);

            // host
            settings.LdapHost = ldap.Uri.Host;

            // secure
            settings.LdapSecure = ldap.SSL.ToString();

            // port
            settings.LdapPort = ldap.Port.ToString();

            // DN
            settings.ProxyDN = ldap.ProxyDN;

            //Pull the password from the store, not the config file. The ldap sync removes it from the config
            Simias.Enterprise.Common.ProxyUser user = new Simias.Enterprise.Common.ProxyUser();
            settings.ProxyPassword = user.Password;

            // context
            ArrayList list = new ArrayList();

            foreach (string context in ldap.SearchContexts)
            {
                list.Add(context);
            }
            settings.SearchContexts = (string[])list.ToArray(typeof(string));

            // interval
            settings.SyncInterval = ldap.SyncInterval.ToString();

            // sync on start
            settings.SyncOnStart = ldap.SyncOnStart.ToString();

            return(settings);
        }