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); }
/// <summary> /// Replace the existing user session, if any, with a new one using /// these parameters. /// </summary> public void ReinitialiseSession(string host, string username, string password, string ldapKey) { SuiteCRMUserSession = new SuiteCRMClient.UserSession(host, username, password, ldapKey, ThisAddIn.AddInTitle, log, Properties.Settings.Default.RestTimeout); }
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); } }
/// <summary> /// Authenticate against CRM using these parameters. /// </summary> /// <param name="host"></param> /// <param name="username"></param> /// <param name="password"></param> /// <param name="ldapKey"></param> /// <returns>True on success.</returns> public bool Authenticate(string host, string username, string password, string ldapKey) { bool result = false; try { if (Properties.Settings.Default.Host != String.Empty) { ReinitialiseSession(host, username, password, ldapKey); try { if (SuiteCRMUserSession.Login()) { LogServerVersion(); result = true; } } catch (Exception any) { Log.Error("Failure while trying to authenticate to CRM", any); } } 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); } } catch (Exception ex) { Log.Error("ThisAddIn.Authenticate", ex); } return(result); }
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); }