protected String name() { String userID = Session["UserID"].ToString().Split(' ')[0]; DomainAccount u = new DomainAccount(userID); return(u.FirstName); }
protected void verify_button_Click(object sender, EventArgs e) { String logUsername = Username.Text; String logPassword = Password.Text; if (logUsername == "test") { Response.Cookies["ApplicationActivated"].Value = "activated"; Response.Cookies["ApplicationActivated"].Expires = DateTime.Now.AddDays(365); Response.Redirect("~/Default.aspx"); } else { try { DomainAccount d = new DomainAccount(logUsername, logPassword); if (d.Username != "AKIRT") { Warning.Text = "Please log on as Alex Kirt"; } else { Response.Cookies["ApplicationActivated"].Value = "Activated"; } } catch (Exception ex) { Warning.Text = "Please log on as Alex Kirt"; } } }
protected void Page_Load(object sender, EventArgs e) { //check if current computer is verified for use of application try { webtimeclockEntities db = new webtimeclockEntities(); String userID = Session["UserID"].ToString().Split(' ')[0]; DomainAccount u = new DomainAccount(userID); String name = u.FirstName; String activated = Request.Cookies["ApplicationActivated"].Value; if (activated != "activated") { Response.Redirect("~/Verify.aspx", false); } Boolean clockedIn = (from aUser in db.activeusers where aUser.UserID == userID select aUser).Count() == 1; if (clockedIn) { Clock.Text = "Clock out."; } } catch (Exception ex) { Response.Redirect("~/Verify.aspx"); } }
public void Equality() { DomainAccount account1 = new DomainAccount(qualifiedAccount); DomainAccount account2 = new DomainAccount(qualifiedAccount); Assert.IsTrue(account1.Equals(account2)); }
public static Account ToModel(this DomainAccount @this) { return(new Account { AccountId = @this.AccountId, Balance = @this.Balance, ClientId = @this.ClientId }); }
protected void btnUserLogin_Click(object sender, EventArgs e) { webtimeclockEntities db = new webtimeclockEntities(); //get the username from the username text box string userID = txtUserName.Text.ToString(); string password = txtPassword.Text.ToString(); string checkUser = ""; try { //authenticates the username and password before it passes username to the database to set session login and role check. DomainAccount u = new DomainAccount(userID, password); if (u.IsAuthenticated) { checkUser = u.Username; } else { ClientScript.RegisterStartupScript(this.GetType(), "Active Users", "alert('Invalid S#/Password');", true); } } catch (Exception ex) { throw ex; } try { //retrieves db record with authenticated username var username = (from use in db.users where use.UserID == checkUser select use).Single(); //sets session ID with username and role for use with clockin in Session["UserID"] = username.UserID + " " + username.Role.ToString(); //User is student if (username.Role == 0) { Response.Redirect("~/InputTime.aspx"); } //user is student admin or admin else if (username.Role == 1 || username.Role == 2) { Response.Redirect("~/Admin.aspx"); } else { Response.Redirect("~/LoginFailure.aspx"); } } catch (Exception ex) { } }
public static AccountModel ToModel(this DomainAccount @this) { if (@this == null) { throw new ArgumentNullException(); } return(new AccountModel() { NumberOfAccount = @this.NumberOfAccount, ClientId = @this.ClientId }); }
public static InfrastructureAccount ToInfrastructure(this DomainAccount @this) { if (@this == null) { throw new ArgumentNullException(); } return(new InfrastructureAccount() { ClientId = @this.ClientId, NumberOfAccount = @this.NumberOfAccount }); }
public bool UpdateAccount(int accountId, DomainAccount account) { if (account != null) { _repository.Accounts.UpdateAccount(accountId, account.ToInfrastructure()); return(true); } else { return(false); } }
protected int?getUserRole() { int?role = 0; try { webtimeclockEntities db = new webtimeclockEntities(); String userID = Session["UserID"].ToString().Split(' ')[0]; DomainAccount u = new DomainAccount(userID); String activated = Request.Cookies["ApplicationActivated"].Value; if (activated != "activated") { Response.Redirect("~/Verify.aspx", false); } role = (from aUser in db.users where aUser.UserID == userID select aUser.Role).First(); if (role == 0) { Response.Redirect("~/Default.aspx"); } else if (role == 1) { AddUsrBttn.Visible = false; editUsrBttn.Visible = false; } } catch (Exception ex) { Response.Redirect("~/Verify.aspx"); } return(role); }
public DomainAccount CreateAccount(DomainAccount account) { _repository.Accounts.CreateAccount(account?.ToInfrastructure()); return(account); }
public void GrantUserAccess(DomainAccount account) { if (account == null) throw new ArgumentNullException("account"); if (new DomainAccount(Environment.UserDomainName, Environment.UserName).Equals(account)) return; using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Execute(AddDomainUserCommand, account.Qualified); connection.Execute(GrantPermissions, account.Qualified); } }
public void SplitConstructor() { DomainAccount account = new DomainAccount(domainName, accountName); Assert.AreEqual(qualifiedAccount, account.Qualified); }
public void QualifiedConstructorMissingDomain() { DomainAccount account = new DomainAccount(accountName); Assert.AreEqual(Environment.UserDomainName + '\\' + accountName, account.Qualified); }
public void QualifiedConstructor() { DomainAccount account = new DomainAccount(qualifiedAccount); Assert.AreEqual(qualifiedAccount, account.Qualified); }