Ejemplo n.º 1
0
        /// <summary>
        /// Initializes an instance of this object.
        /// </summary>
        public User()
        {
            store = Store.GetStore();
            if (store.DefaultDomain == null)
            {
                throw new SimiasException(User.missingDomainMessage);
            }

            // Is the default domain always the correct domain?
            domain = store.GetDomain(store.DefaultDomain);
            if (domain == null)
            {
                throw new SimiasException(User.missingDomainMessage);
            }

            if (domain.IsType("Enterprise") == false)
            {
                throw new SimiasException(User.missingDomainMessage);
            }

            ldapSettings = LdapSettings.Get(Store.StorePath);


            // Make sure the password is set on the admin
            SetAdminPassword();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Call to inform a provider to start a synchronization cycle
        /// </summary>
        /// <returns> True - provider successfully finished a sync cycle,
        /// False - provider failed the sync cycle
        /// </returns>
        public bool Start(Simias.IdentitySynchronization.State State)
        {
            log.Debug("Start called");
            int MaxConnectRetry = 5;

            bool status = false;

            abort = false;
            try
            {
                this.state = State;

                try
                {
                    ldapSettings = LdapSettings.Get(Store.StorePath);
                    log.Debug("new LdapConnection");
                    conn = new LdapConnection();

                    log.Debug("Connecting to: " + ldapSettings.Host + " on port: " + ldapSettings.Port.ToString());
                    conn.SecureSocketLayer = ldapSettings.SSL;
                    for (int i = 1; i <= MaxConnectRetry; i++)
                    {
                        try
                        {
                            conn.Connect(ldapSettings.Host, ldapSettings.Port);
                        }
                        catch (Exception ex)
                        {
                            log.Debug("Failed to connect to : " + ldapSettings.Host + ", retry count: " + i.ToString() + ", Error Message : " + ex.Message);
                            continue;
                        }
                        break;
                    }


                    ProxyUser proxy = new ProxyUser();

                    log.Debug("Binding as: " + proxy.UserDN);
                    conn.Bind(proxy.UserDN, proxy.Password);

                    ProcessSimiasAdmin(conn);
                    ProcessSearchObjects(conn, ldapSettings);
                }
                catch (SimiasShutdownException s)
                {
                    log.Error(s.Message);
                    syncException = s;
                    syncStatus    = Status.SyncThreadDown;
                }
                catch (LdapException e)
                {
                    log.Error(e.LdapErrorMessage);
                    log.Error(e.StackTrace);
                    syncException = e;
                    syncStatus    =
                        (conn == null)
                                                        ? Status.LdapConnectionFailure
                                                        : Status.LdapAuthenticationFailure;

                    state.ReportError(e.LdapErrorMessage);
                }
                catch (Exception e)
                {
                    log.Error(e.Message);
                    log.Error(e.StackTrace);
                    syncException = e;
                    syncStatus    = Status.InternalException;

                    state.ReportError(e.Message);
                }
                finally
                {
                    if (conn != null)
                    {
                        log.Debug("Disconnecting Ldap connection");
                        try{
                            conn.Disconnect();
                        }catch {}
                        conn = null;
                    }
                }
                status = true;
            }
            catch (Exception e)
            {
                log.Error(e.Message);
                log.Error(e.StackTrace);
                State.ReportError(e.Message);
            }

            return(status);
        }