/*
        Metodo que verifica que el usuario este autorizado en el active para ingresar al sistema
        */
        protected void buttonLogin_Click(object sender, EventArgs e)
        {
            String adPath = "LDAP://bsci.bossci.com"; //Fully-qualified Domain Name
            LdapAuthentication adAuth = new LdapAuthentication(adPath);
            try
            {
                if (true == adAuth.IsAuthenticated("BSCI", Login.Text, Password.Text))
                {
                    String groups = adAuth.GetGroups();

                    //Create the ticket, and add the groups.
                    bool isCookiePersistent = false;
                    FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, Login.Text,
                    DateTime.Now, DateTime.Now.AddMinutes(60), isCookiePersistent, groups);

                    //Encrypt the ticket.
                    String encryptedTicket = FormsAuthentication.Encrypt(authTicket);

                    //Create a cookie, and then add the encrypted ticket to the cookie as data.
                    HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);

                    if (true == isCookiePersistent)
                        authCookie.Expires = authTicket.Expiration;

                    //Add the cookie to the outgoing cookies collection.
                    Response.Cookies.Add(authCookie);

                    //Save data in server audit trail
                    InsertActionServerAuditTrailView view = new InsertActionServerAuditTrailView();
                    AuditService auditService = new AuditService();
                    String reason = "User Log In";
                    String user = Context.User.Identity.Name;
                    view.Reason = reason;
                    view.StationIP = General.getIp(this.Page);
                    view.UserName = Login.Text;
                    view.Action = "Login user";
                    view.NewValues = "N/A";
                    auditService.insertAuditTrail(view);

                    //Redirect now.
                    Response.Redirect("~/Default.aspx",false);
                }
                else
                {
                    errorLabel.Text = "Authentication did not succeed. Check user name and password.";
                }
            }
            catch (Exception ex)
            {
                errorLabel.Text = "Error authenticating. " + ex.Message;
            }
        }
 private void accessReport(String report)
 {
     InsertActionServerAuditTrailView view = new InsertActionServerAuditTrailView();
     AuditService auditService = new AuditService();
     String reason = "User access " + report;
     String user = Context.User.Identity.Name;
     view.Reason = reason;
     view.StationIP = General.getIp(this.Page);
     view.UserName = user;
     view.Action = "View Report";
     view.NewValues = "N/A";
     auditService.insertAuditTrail(view);
 }