public UserInfo GetContactInfo(string UserId, int UserRid, SessionInfo S)
        {
            SqlCommand Cmd = GetCommand("AUTH_GetUserInfo", S);

            if (UserId != null)
            {
                Cmd.Parameters["@UserId"].Value = UserId;
            }
            if (UserId == null)
            {
                Cmd.Parameters["@UserRid"].Value = UserRid;
            }
            SqlDataReader Reader = Cmd.ExecuteReader();
            APDSUserInfo  Result = new APDSUserInfo();

            if (Reader.Read())
            {
                Result.CopyFrom(Reader);
            }
            Reader.Close();
            return(new UserInfo(Result));
        }
        public UserInfo SSOAuthenticate(string Password, SessionInfo S, bool IsOpenTokenExists)
        {
            APDSUserInfo Result = new APDSUserInfo();
            //RFC 185138 - AD Integration - CH2 START- Commented the lockedout check and password parameter input to the SP in SSOAuthenticate  method
            //Result.IsLockedOut = CheckLockoutCounterNew(S);
            //// Changed by Cognizant to fix exception while returning lockout is null. Doing a typecast while returning
            //if (Result.IsLockedOut) return new UserInfo(Result);
            SqlCommand Cmd = GetCommand("AUTH_Authenticate", S);

            //SSO-Integration.Bug fix1: Added new checking for IsOpenTokenExists. If it is true, then assign null alue to @Password. This is to avoid encrypting the empty string
            //if (IsOpenTokenExists == true)
            //{
            //    Cmd.Parameters["@Password"].Value = null;
            //}
            //else
            //{
            //    Cmd.Parameters["@Password"].Value = MD5Hash(Password);
            //}
            //RFC 185138 - AD Integration - CH2 END -Commented the lockedout check and password parameter input to the SP in SSoAuthenticate  method
            Cmd.Parameters["@Timeout"].Value = SessionTimeout;

            if (IsOpenTokenExists == true)
            {
                Cmd.Parameters["@OpenTokenExists"].Value = 1;
            }
            else
            {
                Cmd.Parameters["@OpenTokenExists"].Value = 0;
            }
            SqlDataReader Reader           = Cmd.ExecuteReader();
            string        ErrorInformation = string.Empty;
            ErrorInfo     errorInfo        = null;
            UserInfo      userInfo         = null;

            if (Reader.Read())
            {
                try
                {
                    if (Reader.FieldCount > 1)
                    {
                        //RFC 185138 - AD Integration - CH5 START - Commented copy of passwordlife span parameter and added the new copyfrom method
                        //Result.CopyFrom(Reader, PasswordLifeSpan);
                        Result.CopyFrom(Reader);
                        //RFC 185138 - AD Integration - CH5 END - Commented copy of passwordlife span parameter and added the new copyfrom method
                        userInfo = new UserInfo(Result);
                    }
                    else
                    {
                        ErrorInformation = Reader["ERRORINFO"].ToString();
                        userInfo         = new UserInfo(Result);
                        errorInfo        = new ErrorInfo("", ErrorInformation.ToString(), "SalesX");
                        userInfo.AddError(errorInfo);
                    }
                    Reader.Close();
                }
                catch (Exception ex)
                {
                    string logMessage = ex.Message;
                    CSAAWeb.AppLogger.Logger.Log(logMessage);
                }
            }
            return(userInfo);
        }
        public UserInfo Authenticate(string Password, SessionInfo S)
        {
            string       applicationName = string.Empty;
            UserInfo     userInfo        = null;
            APDSUserInfo Result          = new APDSUserInfo();
            //RFC 185138 - AD Integration - CH1 START - Commented the lockedout check and password parameter input to the SP in Authenticate  method
            //Result.IsLockedOut = CheckLockoutCounterNew(S);
            //// Changed by Cognizant to fix exception while returning lockout is null. Doing a typecast while returning
            //if (Result.IsLockedOut) return new UserInfo(Result);
            SqlCommand Cmd = GetCommand("AUTH_Authenticate", S);

            //Cmd.Parameters["@Password"].Value = MD5Hash(Password);
            //RFC 185138 - AD Integration - CH1 END - Commented the lockedout check and password parameter input to the SP in Authenticate  method
            Cmd.Parameters["@Timeout"].Value = SessionTimeout;
            SqlDataReader Reader = Cmd.ExecuteReader();

            //SSO-Integration.Ch2: Start of Code - Existing code has been commented and New code has been added to handle the error messages returned by the stored procedure

            //if (Reader.Read()) Result.CopyFrom(Reader, PasswordLifeSpan);
            //Reader.Close();
            ////if (Result.Authenticated) ResetLockoutCounter(S.CurrentUser);
            //return new UserInfo(Result);


            if (ConfigurationSettings.AppSettings["SSOIntegratedApplications"] != null && ConfigurationSettings.AppSettings["SSOIntegratedApplications"].ToString() != string.Empty)
            {
                applicationName = ConfigurationSettings.AppSettings["SSOIntegratedApplications"].ToString();
            }
            if (applicationName.IndexOf(S.AppName) >= 0)
            {
                string    ErrorInformation = string.Empty;
                ErrorInfo errorInfo        = null;

                if (Reader.Read())
                {
                    try
                    {
                        if (Reader.FieldCount > 1)
                        {
                            //RFC 185138 - AD Integration - CH3 Start - Commented the lockedout check and copy of passwordlife span parameter and added the new copyfrom method
                            //Result.CopyFrom(Reader, PasswordLifeSpan);
                            //if (Result.Authenticated) ResetLockoutCounter(S.CurrentUser);
                            Result.CopyFrom(Reader);
                            //RFC 185138 - AD Integration - CH3 END - Commented the lockedout check and copy of passwordlife span parameter and added the new copyfrom method
                            userInfo = new UserInfo(Result);
                        }
                        else
                        {
                            ErrorInformation = Reader["ERRORINFO"].ToString();
                            userInfo         = new UserInfo(Result);
                            errorInfo        = new ErrorInfo("", ErrorInformation.ToString(), "SalesX");
                            userInfo.AddError(errorInfo);
                        }
                        Reader.Close();
                    }
                    catch (Exception ex)
                    {
                        string logMessage = ex.Message;
                        CSAAWeb.AppLogger.Logger.Log(logMessage);
                    }
                }
            }
            else
            {
                //RFC 185138 - AD Integration - CH4 start - Commented the lockedout check and copy of passwordlife span parameter and added the new copyfrom method
                //if (Reader.Read()) Result.CopyFrom(Reader, PasswordLifeSpan);
                //if (Result.Authenticated) ResetLockoutCounter(S.CurrentUser);
                if (Reader.Read())
                {
                    Result.CopyFrom(Reader);
                }
                //RFC 185138 - AD Integration - CH4 END - Commented the lockedout check and copy of passwordlife span parameter and added the new copyfrom method
                Reader.Close();
                userInfo = new UserInfo(Result);
            }

            //return new UserInfo(Result);
            return(userInfo);
            //SSO-Integration.Ch2: End of Code
        }