Beispiel #1
0
        public ActionResult login(string UserId, string UserPassword)
        {
            LDAPAutenticadorController aut = new LDAPAutenticadorController();
            ArrayList gruposDe             = new ArrayList();
            ArrayList propUsers            = new ArrayList();

            try
            {
                if (aut.autenticado((string)Session["dominio"], UserId, UserPassword) == true)
                {
                    // lblUsuario.Text = aut.getCN();

                    propUsers = aut.getListaPropiedades();
                    //ddlUsuarios.Items.Clear();
                    //ddlUsuarios.Items.Add(new ListItem(propUsers[0] as string));

                    if (propUsers.Count > 1)
                    {
                        ViewBag.UserName      = propUsers[0] as string;
                        ViewBag.UserFirstName = propUsers[1] as string;
                        ViewBag.UserLastName  = propUsers[2] as string;

                        return(RedirectToAction("Index"));
                    }

                    //llenarGrupos(lblUsuario.Text);

                    //gruposDe = aut.GetGroups();
                    //listaGrupos.Items.Clear();
                    //for (int i = 0; i < gruposDe.Count; i++)
                    //{
                    //    listaGrupos.Items.Add(new ListItem(gruposDe[i] as string));
                    //    if (gruposDe[i] as string == "Administrators")
                    //    {
                    //        Response.Write("Bienvenido administrador");
                    //    }
                    //}
                }
            }

            catch (Exception e)
            {
                @ViewBag.Error = "Error al ingresar, por favor comunicarse con el administrador " + e.ToString();
            }

            return(View());
        }
Beispiel #2
0
        public ActionResult GetUser()
        {
            string UserLog = User.Identity.Name;

            string[] words  = UserLog.Split('\\');
            string   UserId = words[1];

            //string adPath = "LDAP://atg.root"; // + Session["dominio"];
            //LDAPAutenticadorController aut = new LDAPAutenticadorController(adPath);
            LDAPAutenticadorController aut = new LDAPAutenticadorController();
            ArrayList propUsers            = new ArrayList();
            var       data = new User();

            propUsers = aut.GetInfoUser(words[1]);
            //ddlUsuarios.Items.Clear();
            //ddlUsuarios.Items.Add(new ListItem(propUsers[0] as string));

            var userTemp = db.User.Where(u => u.UserId == UserId).FirstOrDefault();

            if (propUsers.Count > 1)
            {
                data.UserId      = UserId;
                data.UserName    = propUsers[0] as string;
                data.UserOffice  = propUsers[1] as string;
                data.UserMail    = propUsers[2] as string;
                data.UserCountry = propUsers[3] as string;
                data.UserCity    = propUsers[4] as string;
                data.UserTitle   = propUsers[5] as string;
                data.AnswerList  = db.Answer.Include(q => q.Question).Where(a => a.UserId == UserId).ToList();

                if (userTemp == null)
                {
                    createUser(data);
                }
            }
            else
            if (userTemp != null)
            {
                data.UserId      = UserId;
                data.UserName    = userTemp.UserName;
                data.UserOffice  = userTemp.UserOffice;
                data.UserMail    = userTemp.UserMail;
                data.UserCountry = userTemp.UserCountry;
                data.UserCity    = userTemp.UserCity;
                data.UserTitle   = userTemp.UserTitle;
                data.AnswerList  = db.Answer.Include(q => q.Question).Where(a => a.UserId == UserId).ToList();
            }
            var status  = propUsers[6] as string;
            var isornot = aut.isUserLocked;

            if (decimal.Parse(status) > 0 || isornot)
            {
                ViewBag.Status = true;
            }

            //bool FlagAccountLocked = aut.isUserLocked;

            //if (FlagAccountLocked)
            //{
            //    ViewBag.Status = true;
            //}

            return(PartialView("index", data));
        }