public bool Authenticate()
        {
            bool result = false;

            try
            {
                if (settings.host != String.Empty)
                {
                    SuiteCRMUserSession =
                        new SuiteCRMClient.UserSession(
                            settings.host,
                            settings.username,
                            settings.password,
                            settings.LDAPKey,
                            log,
                            Settings.RestTimeout);
                    SuiteCRMUserSession.AwaitingAuthentication = true;
                    try
                    {
                        if (settings.IsLDAPAuthentication)
                        {
                            SuiteCRMUserSession.AuthenticateLDAP();
                        }
                        else
                        {
                            SuiteCRMUserSession.Login();
                        }

                        if (SuiteCRMUserSession.IsLoggedIn)
                        {
                            result = true;
                        }
                    }
                    catch (Exception any)
                    {
                        ShowAndLogError(any, "Failure while trying to authenticate to CRM", "Login failure");
                    }
                }
                else
                {
                    // We don't have a URL to connect to, dummy the connection.
                    SuiteCRMUserSession =
                        new SuiteCRMClient.UserSession(
                            String.Empty,
                            String.Empty,
                            String.Empty,
                            String.Empty,
                            log,
                            Settings.RestTimeout);
                }

                SuiteCRMUserSession.AwaitingAuthentication = false;
            }
            catch (Exception ex)
            {
                log.Error("ThisAddIn.Authenticate", ex);
            }

            return(result);
        }
예제 #2
0
        public void Authenticate()
        {
            try
            {
                if (settings.host != String.Empty)
                {
                    SuiteCRMUserSession =
                        new SuiteCRMClient.UserSession(
                            settings.host,
                            settings.username,
                            settings.password,
                            settings.LDAPKey,
                            log,
                            Settings.RestTimeout);
                    SuiteCRMUserSession.AwaitingAuthentication = true;
                    try
                    {
                        if (settings.IsLDAPAuthentication)
                        {
                            SuiteCRMUserSession.AuthenticateLDAP();
                        }
                        else
                        {
                            SuiteCRMUserSession.Login();
                        }

                        if (SuiteCRMUserSession.IsLoggedIn)
                        {
                            return;
                        }
                    }
                    catch (Exception)
                    {
                        // Swallow exception(!)
                    }
                }
                else
                {
                    // We don't have a URL to connect to, dummy the connection.
                    SuiteCRMUserSession =
                        new SuiteCRMClient.UserSession(
                            String.Empty,
                            String.Empty,
                            String.Empty,
                            String.Empty,
                            log,
                            Settings.RestTimeout);
                }

                SuiteCRMUserSession.AwaitingAuthentication = false;
            }
            catch (Exception ex)
            {
                log.Error("ThisAddIn.Authenticate", ex);
            }
        }
예제 #3
0
        public bool Authenticate()
        {
            bool result = false;

            try
            {
                if (Properties.Settings.Default.Host != String.Empty)
                {
                    SuiteCRMUserSession =
                        new SuiteCRMClient.UserSession(
                            Properties.Settings.Default.Host,
                            Properties.Settings.Default.Username,
                            Properties.Settings.Default.Password,
                            Properties.Settings.Default.LDAPKey,
                            ThisAddIn.AddInTitle,
                            log,
                            Properties.Settings.Default.RestTimeout);
                    SuiteCRMUserSession.AwaitingAuthentication = true;
                    try
                    {
                        if (Properties.Settings.Default.IsLDAPAuthentication)
                        {
                            SuiteCRMUserSession.AuthenticateLDAP();
                        }
                        else
                        {
                            SuiteCRMUserSession.Login();
                        }

                        if (SuiteCRMUserSession.IsLoggedIn)
                        {
                            LogServerVersion();

                            result = true;
                        }
                    }
                    catch (Exception any)
                    {
                        ShowAndLogError(
                            any,
                            catalogue.GetString("Failure while trying to authenticate to CRM"),
                            catalogue.GetString("Login failure"));
                    }
                }
                else
                {
                    // We don't have a URL to connect to, dummy the connection.
                    SuiteCRMUserSession =
                        new SuiteCRMClient.UserSession(
                            String.Empty,
                            String.Empty,
                            String.Empty,
                            String.Empty,
                            ThisAddIn.AddInTitle,
                            log,
                            Properties.Settings.Default.RestTimeout);
                }

                SuiteCRMUserSession.AwaitingAuthentication = false;
            }
            catch (Exception ex)
            {
                log.Error("ThisAddIn.Authenticate", ex);
            }

            return(result);
        }