Пример #1
0
    public static string activeDirectory(string cuenta)
    {
        string result    = "";
        String exception = String.Empty;

        try
        {
            DataTable dt = DGActiveDirectory.getGeneralInfo(DGActiveDirectory.setDomainVariablesAndGetSearchResult("GDL|USA", cuenta, ref exception), cuenta);

            if (dt != null)
            {
                result = dt.Rows[0]["Email"].ToString();
            }

            return(result);
        }
        catch (Exception x)
        {
            log.Error(x);
            return(result);
        }
    }
Пример #2
0
    private string CheckEmployeeID()
    {
        string result  = "Error";
        string idusrAD = "";

        try
        {
            idusrAD = DGActiveDirectory.getGeneralInfo(DGActiveDirectory.setDomainVariablesAndGetSearchResult("GDL|USA", Session["usernameInj"].ToString(), ref result), Session["usernameInj"].ToString()).Rows[0]["idEmpleado"].ToString();
            if (!Session["idEmpleado"].ToString().Equals(idusrAD) && !string.IsNullOrEmpty(Session["idEmpleado"].ToString()))
            {
                result = data.executeStoreProcedureString("UpdateEmployeeID", new Dictionary <string, object>()
                {
                    { "@username", Session["usernameInj"].ToString() },
                    { "@idEmpleado", idusrAD }
                });
            }
        }
        catch (Exception e)
        {
            log.Error(e);
        }
        return(result);
    }
Пример #3
0
    protected void txtCuenta_TextChanged(object sender, EventArgs e)
    {
        hdn_exist.Value = "1";

        if (!cbxActiveDirectory.Checked)
        {
            txtEmail.Enabled = true;
            return;
        }
        txtEmail.Enabled = false;
        foreach (ListItem item in ddlPlanta.Items)
        {
            item.Enabled  = true;
            item.Selected = false;
        }
#if DEBUG
        if (txtCuenta.Text.Trim().CompareTo("recepcion") == 0)
        {
            ltNombreUsuario.Text = "Usuario recepcion";
            return;
        }
        else if (txtCuenta.Text.Trim().CompareTo("planta") == 0)
        {
            ltNombreUsuario.Text = "Usuario planta";
            return;
        }
        else if (txtCuenta.Text.Trim().CompareTo("planta2") == 0)
        {
            ltNombreUsuario.Text = "Usuario planta 2";
            return;
        }
        else if (txtCuenta.Text.Trim().CompareTo("apoyo") == 0)
        {
            ltNombreUsuario.Text = "Usuario apoyo";
            return;
        }
        else if (txtCuenta.Text.Trim().CompareTo("apoyo2") == 0)
        {
            ltNombreUsuario.Text = "Usuario apoyo 2";
            return;
        }
        else if (txtCuenta.Text.Trim().CompareTo("apoyo3") == 0)
        {
            ltNombreUsuario.Text = "Usuario apoyo 3";
            return;
        }
        else if (txtCuenta.Text.Trim().CompareTo("apoyo4") == 0)
        {
            ltNombreUsuario.Text = "Usuario apoyo 4";
            return;
        }
#endif
        try
        {
            String exception = String.Empty;
            txtCuenta.Text = txtCuenta.Text.ToLower().Trim().Replace("*", "");
            if (string.IsNullOrEmpty(txtCuenta.Text))
            {
                popUpMessageControl1.setAndShowInfoMessage((string)GetLocalResourceObject("ErrorAttempt"), Comun.MESSAGE_TYPE.Warning);
                return;
            }
            DataTable tabla = DGActiveDirectory.getGeneralInfo(DGActiveDirectory.setDomainVariablesAndGetSearchResult("GDL|USA", txtCuenta.Text, ref exception), txtCuenta.Text);

            if (null == tabla)
            {
                Log.Error(exception);
                popUpMessageControl1.setAndShowInfoMessage((string)GetLocalResourceObject("ErrorAttempt"), Comun.MESSAGE_TYPE.Warning);
                hdn_exist.Value = "0";
                txtCuenta.Text  = "";
                limpiaCampos();
            }
            else
            {
                ViewState["AD_Info"]   = tabla;
                txtNumeroEmpleado.Text = tabla.Rows[0]["id_Empleado"].ToString();
                ltNombreUsuario.Text   = tabla.Rows[0]["FirstName"] + " " + tabla.Rows[0]["LastName"];
                txtNombre.Text         = ltNombreUsuario.Text;
                txtEmail.Text          = tabla.Rows[0]["Email"] as string;
                hdn_exist.Value        = "1";

                //if (string.IsNullOrEmpty(tabla.Rows[0]["idPlanta"].ToString()))
                //{
                //    popUpMessageControl1.setAndShowInfoMessage((string)GetLocalResourceObject("idPlanta"), Comun.MESSAGE_TYPE.Warning);
                //    //limpiaCampos();
                //    //hdn_exist.Value = "0";
                //}
                //else
                //{
                //    ddlPlanta.Items.FindByValue(tabla.Rows[0]["idPlanta"].ToString()).Selected = true;
                //    ddlPlanta.Items.FindByValue(tabla.Rows[0]["idPlanta"].ToString()).Enabled = false;
                //}

                if (string.IsNullOrEmpty(tabla.Rows[0]["idEmpleado"].ToString()))
                {
                    popUpMessageControl1.setAndShowInfoMessage((string)GetLocalResourceObject("idEmpleado"), Comun.MESSAGE_TYPE.Warning);
                    limpiaCampos();
                    hdn_exist.Value = "0";
                }
            }
        }
        catch (NullReferenceException nre)
        {
            popUpMessageControl1.setAndShowInfoMessage(GetLocalResourceObject("nocoincideplanta").ToString(), Comun.MESSAGE_TYPE.Error);

            Log.Error(nre);
        }
        catch (Exception es)
        {
            Log.Error(es);
        }
    }