/// <summary>
        /// Authenticates the A duser.
        /// </summary>
        /// <remarks>
        /// Sequence Diagram:<br/>
        ///     <img src="SequenceDiagrams/SD_PrintReleaseDevice.Browser.SelfRegistration.AuthenticateADuser.jpg"/>
        /// </remarks>
        private void AuthenticateADuser()
        {
            string username     = TextBoxUserName.Text.Trim();
            string userPassword = TextBoxPassword.Text.Trim();
            string userDomain   = TextBoxDomain.Text;

            string domainName     = string.Empty;
            string domainUserName = string.Empty;
            string domainPassword = string.Empty;

            string ActiveDirectorySettings = ApplicationSettings.ProvideActiveDirectorySettings(userDomain, ref domainName, ref domainUserName, ref domainPassword);

            if (Ldap.UserExists(username, userDomain, domainUserName, domainPassword))
            {
                if (AppAuthentication.isValidUser(username, userPassword, userDomain, userSource))
                {
                    BuildFutureLoginForm();
                }
                else
                {
                    TableCommunicator.Visible             = true;
                    TableSelfRegistrationControls.Visible = false;
                    LabelCommunicatorNote.Text            = Localization.GetServerMessage(Constants.APPLICATION_TYPE_OSA_CLASSIC, deviceCulture, "INVALID_PASSWORD");
                    return;
                }
            }
            else
            {
                isClearAllFields                      = true;
                TableCommunicator.Visible             = true;
                TableSelfRegistrationControls.Visible = false;
                LabelCommunicatorNote.Text            = Localization.GetServerMessage(Constants.APPLICATION_TYPE_OSA_CLASSIC, deviceCulture, "INVALID_USER_TRY_AGAIN");
                return;
            }
        }
Esempio n. 2
0
        private void AuthenticateADuser(string userName, string password, string selectedDomain)
        {
            string username     = userName;
            string userPassword = password;
            string userDomain   = selectedDomain;

            string domainName     = string.Empty;
            string domainUserName = string.Empty;
            string domainPassword = string.Empty;

            string ActiveDirectorySettings = ApplicationSettings.ProvideActiveDirectorySettings(userDomain, ref domainName, ref domainUserName, ref domainPassword);

            if (Ldap.UserExists(username, userDomain, domainUserName, domainPassword))
            {
                if (AppAuthentication.isValidUser(username, userPassword, userDomain, userSource))
                {
                    AddUserDetails(userName, userPassword, userDomain);
                }
                else
                {
                    Response.Redirect("MessageForm.aspx?FROM=SelfRegistration.aspx&MESS=InvalidPassword");
                    // LabelCommunicatorNote.Text = Localization.GetServerMessage(Constants.APPLICATION_TYPE_OSA_CLASSIC, deviceCulture, "INVALID_PASSWORD");
                }
            }
            else
            {
                Response.Redirect("MessageForm.aspx?FROM=SelfRegistration.aspx&MESS=invalidUserTryAgain");
                //LabelCommunicatorNote.Text = Localization.GetServerMessage(Constants.APPLICATION_TYPE_OSA_CLASSIC, deviceCulture, "INVALID_USER_TRY_AGAIN");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Validates Secure card.
        /// </summary>
        /// <param name="cardID">Card ID.</param>
        /// <param name="password">Password.</param>
        /// <param name="userDomain">User domain.</param>
        /// <remarks>
        /// Sequence Diagram:<br/>
        ///     <img src="SequenceDiagrams/SD_PrintReleaseEA.Mfp.CardLogOn.ValidateSecureCard.jpg"/>
        /// </remarks>
        private void ValidateSecureCard(string cardID, string password, string userDomain)
        {
            bool isValidFascilityCode = false;
            bool isValidCard          = false;
            bool isCardExixts         = DataManagerDevice.Controller.Card.IsCardExists(cardID);

            if (isCardExixts)
            {
                string cardValidationInfo = "";
                string slicedCard         = Card.ProvideCardTransformation(null, Session["cardReaderType"] as string, cardID, ref isValidFascilityCode, ref isValidCard, ref cardValidationInfo);
                if (isValidFascilityCode && !string.IsNullOrEmpty(slicedCard))
                {
                    if (string.Compare(cardID, slicedCard, false) == 0) //cardID.IndexOf(sliceCard) > -1
                    {
                        DataSet dsCardDetails = DataManagerDevice.ProviderDevice.Users.ProvideCardUserDetails(cardID, userSource);
                        if (dsCardDetails.Tables[0].Rows.Count > 0)
                        {
                            //if (string.Compare(cardID, slicedCard, true) == 0) //cardID.IndexOf(sliceCard) > -1
                            //{

                            // Change the user source as per card ID;

                            string userCardSource = dsCardDetails.Tables[0].Rows[0]["USR_SOURCE"].ToString();
                            userSource            = userCardSource;
                            Session["UserSource"] = userSource;

                            bool isCardActive = bool.Parse(dsCardDetails.Tables[0].Rows[0]["REC_ACTIVE"].ToString());
                            domainName = dsCardDetails.Tables[0].Rows[0]["USR_DOMAIN"].ToString();
                            if (isCardActive)
                            {
                                allowedRetiresForLogin = int.Parse(DataManagerDevice.ProviderDevice.ApplicationSettings.ProvideSetting("Allowed retries for user login"), CultureInfo.CurrentCulture);
                                string userID = dsCardDetails.Tables[0].Rows[0]["USR_ID"].ToString();
                                Session["UserID"] = userID;
                                string hashedPin            = Protector.ProvideEncryptedPin(password);
                                string userAuthenticationOn = dsCardDetails.Tables[0].Rows[0]["USR_ATHENTICATE_ON"].ToString();
                                // Authenticate PIN based on User Future Login Selection
                                if (userAuthenticationOn == Constants.AUTHENTICATE_FOR_PIN)
                                {
                                    if (hashedPin != dsCardDetails.Tables[0].Rows[0]["USR_PIN"].ToString())
                                    {
                                        if (allowedRetiresForLogin > 0)
                                        {
                                            isPinRetry = true;
                                            CheckCardRetryCount(userID, allowedRetiresForLogin);
                                        }
                                        else
                                        {
                                            Session["CardID"] = null;
                                            Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=invalidPin");
                                        }
                                        return;
                                    }
                                }
                                else
                                {
                                    string isSaveNetworkPassword = Session["NETWORKPASSWORD"].ToString();

                                    // If user source is AD/DM and network password is not saved
                                    // Then Authenticate user in Active Directory/Domain
                                    if (userSource != Constants.USER_SOURCE_DB && isSaveNetworkPassword == "False")
                                    {
                                        // Validate users based on source
                                        if (!AppAuthentication.isValidUser(userID, password, userDomain, userSource))
                                        {
                                            if (allowedRetiresForLogin > 0)
                                            {
                                                isPinRetry = false;
                                                CheckCardRetryCount(userID, allowedRetiresForLogin);
                                            }
                                            else
                                            {
                                                Session["CardID"] = null;
                                                Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=InvalidPassword");
                                            }
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        // Check password is not null
                                        // Encrypt the password && Compare with Database password field
                                        if (!string.IsNullOrEmpty(password) && Protector.ProvideEncryptedPassword(password) != dsCardDetails.Tables[0].Rows[0]["USR_PASSWORD"].ToString())
                                        {
                                            if (allowedRetiresForLogin > 0)
                                            {
                                                isPinRetry = false;
                                                CheckCardRetryCount(userID, allowedRetiresForLogin);
                                            }
                                            else
                                            {
                                                Session["CardID"] = null;
                                                Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=InvalidPassword");
                                            }
                                            return;
                                        }
                                    }
                                }
                                string lastLogin = dsCardDetails.Tables[0].Rows[0]["REC_CDATE"].ToString();
                                if (string.IsNullOrEmpty(lastLogin) && userProvisioning == "First Time Use")
                                {
                                    if (!string.IsNullOrEmpty(dsCardDetails.Tables[0].Rows[0]["USR_NAME"].ToString()))
                                    {
                                        userID = dsCardDetails.Tables[0].Rows[0]["USR_NAME"].ToString();
                                    }
                                    Session["ftuUserID"]    = userID;
                                    Session["Username"]     = dsCardDetails.Tables[0].Rows[0]["USR_NAME"].ToString();
                                    Session["ftuUsersysID"] = dsCardDetails.Tables[0].Rows[0]["USR_ACCOUNT_ID"].ToString();
                                    string printJobDomainName = DataManagerDevice.ProviderDevice.ApplicationSettings.ProvideDomainName(domainName);
                                    Session["DomainName"] = printJobDomainName;
                                    Response.Redirect("FirstTimeUse.aspx");
                                }
                                string userSysID = dsCardDetails.Tables[0].Rows[0]["USR_ACCOUNT_ID"].ToString();
                                string DbuserID  = dsCardDetails.Tables[0].Rows[0]["USR_ID"].ToString();
                                if (DbuserID.ToLower() == "admin" || DbuserID.ToLower() == "administrator")
                                {
                                    Response.Redirect("MessageForm.aspx?FROM=CardLogOn.aspx&MESS=adminUserID");
                                    return;
                                }
                                Session["PRServer"]     = "";
                                Session["UserID"]       = DbuserID;
                                Session["Username"]     = dsCardDetails.Tables[0].Rows[0]["USR_NAME"].ToString();
                                Session["UserSystemID"] = userSysID;
                                if (userSource != Constants.USER_SOURCE_DB)
                                {
                                    string printJobDomainName = DataManagerDevice.ProviderDevice.ApplicationSettings.ProvideDomainName(domainName);
                                    Session["DomainName"] = printJobDomainName;
                                }
                                string createDate = dsCardDetails.Tables[0].Rows[0]["REC_CDATE"].ToString();
                                if (string.IsNullOrEmpty(createDate))
                                {
                                    string updateCDate = DataManagerDevice.Controller.Users.UpdateCDate(userSysID);
                                }
                                RedirectPage();
                                return;
                            }
                            else
                            {
                                Session["CardID"] = null;
                                Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=AccountDisabled");
                            }
                        }
                        else
                        {
                            if (userProvisioning == "Self Registration" && userSource == "AD")
                            {
                                SelfRegisterCard();
                            }
                            else
                            {
                                Session["CardID"] = null;
                                Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=cardInfoNotFoundConsultAdmin");
                            }
                        }
                    }
                    else
                    {
                        Session["CardID"] = null;
                        Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=invalidCardId");
                    }
                }
                else
                {
                    if (!isValidFascilityCode)
                    {
                        Session["CardID"] = null;
                        Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=invalidCardId");
                    }
                    else
                    {
                        if (userProvisioning == "Self Registration" && userSource == "AD")
                        {
                            SelfRegisterCard();
                        }
                        else
                        {
                            Session["CardID"] = null;
                            Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=cardInfoNotFoundConsultAdmin");
                        }
                    }
                }
            }
            else
            {
                if (userProvisioning == "Self Registration" && userSource == "AD")
                {
                    SelfRegisterCard();
                }
                else
                {
                    Session["CardID"] = null;
                    Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=cardInfoNotFoundConsultAdmin");
                }
            }
        }