/// <summary>Creates well formatted XML - includes all properties of User</summary> public string ToXml() { StringBuilder sbReturn = null; sbReturn = new StringBuilder(); sbReturn.Append("<User>\n"); sbReturn.Append("<" + TAG_ID + ">" + UserID + "</" + TAG_ID + ">\n"); sbReturn.Append("<" + TAG_USER_ROLE_ID + ">" + UserRoleID + "</" + TAG_USER_ROLE_ID + ">\n"); if (!dtNull.Equals(DateCreated)) { sbReturn.Append("<" + TAG_DATE_CREATED + ">" + DateCreated.ToString() + "</" + TAG_DATE_CREATED + ">\n"); } else { sbReturn.Append("<" + TAG_DATE_CREATED + "></" + TAG_DATE_CREATED + ">\n"); } if (!dtNull.Equals(DateModified)) { sbReturn.Append("<" + TAG_DATE_MODIFIED + ">" + DateModified.ToString() + "</" + TAG_DATE_MODIFIED + ">\n"); } else { sbReturn.Append("<" + TAG_DATE_MODIFIED + "></" + TAG_DATE_MODIFIED + ">\n"); } sbReturn.Append("<" + TAG_FIRSTNAME + ">" + Firstname + "</" + TAG_FIRSTNAME + ">\n"); sbReturn.Append("<" + TAG_MIDDLENAME + ">" + Middlename + "</" + TAG_MIDDLENAME + ">\n"); sbReturn.Append("<" + TAG_LASTNAME + ">" + Lastname + "</" + TAG_LASTNAME + ">\n"); sbReturn.Append("<" + TAG_USERNAME + ">" + Username + "</" + TAG_USERNAME + ">\n"); sbReturn.Append("<" + TAG_PASSWD + ">" + Passwd + "</" + TAG_PASSWD + ">\n"); sbReturn.Append("<" + TAG_PICTURE_URL + ">" + PictureUrl + "</" + TAG_PICTURE_URL + ">\n"); sbReturn.Append("<" + TAG_PICTURE + ">" + Picture + "</" + TAG_PICTURE + ">\n"); sbReturn.Append("<" + TAG_IS_DISABLED + ">" + IsDisabled + "</" + TAG_IS_DISABLED + ">\n"); if (!dtNull.Equals(LastLoginDate)) { sbReturn.Append("<" + TAG_LAST_LOGIN_DATE + ">" + LastLoginDate.ToString() + "</" + TAG_LAST_LOGIN_DATE + ">\n"); } else { sbReturn.Append("<" + TAG_LAST_LOGIN_DATE + "></" + TAG_LAST_LOGIN_DATE + ">\n"); } sbReturn.Append("</User>" + "\n"); return(sbReturn.ToString()); }
public override int GetHashCode() { int result = 1; result = (result * 397) ^ (Comment != null ? Comment.GetHashCode() : 0); result = (result * 397) ^ (Email != null ? Email.GetHashCode() : 0); result = (result * 397) ^ (FailedPasswordAttemptsCount != null ? FailedPasswordAttemptsCount.GetHashCode() : 0); result = (result * 397) ^ (FailedPasswordAttemptWindowStart != null ? FailedPasswordAttemptWindowStart.GetHashCode() : 0); result = (result * 397) ^ Id.GetHashCode(); result = (result * 397) ^ IsApproved.GetHashCode(); result = (result * 397) ^ IsFirstTimeUser.GetHashCode(); result = (result * 397) ^ IsLockedOut.GetHashCode(); result = (result * 397) ^ (LastActivityDate != null ? LastActivityDate.GetHashCode() : 0); result = (result * 397) ^ (LastLoginDate != null ? LastLoginDate.GetHashCode() : 0); result = (result * 397) ^ (LastPasswordChangeDate != null ? LastPasswordChangeDate.GetHashCode() : 0); result = (result * 397) ^ (Password != null ? Password.GetHashCode() : 0); result = (result * 397) ^ (PasswordKey != null ? PasswordKey.GetHashCode() : 0); result = (result * 397) ^ (Username != null ? Username.GetHashCode() : 0); result = (result * 397) ^ UserType.GetHashCode(); return(result); }
public async Task <ClaimsIdentity> GenerateUserIdentityAsync(UserManager <ApplicationUser> manager) { // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); // Add custom user claims here userIdentity.AddClaim(new Claim(ClaimTypeCustomize.UserRole, RoleId.ToString())); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.RoleName, RoleName ?? "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.LastLoginDate, LastLoginDate != null ? LastLoginDate.ToString() : "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.Email, Email != null ? Email.ToString() : "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.LastName, LastName ?? "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.FirstName, FirstName ?? "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.FullName, FullName ?? "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.InstitutionId, InstitutionId.ToString())); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.InstitutionName, InstitutionName ?? "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.DeptCode, DeptCode ?? "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.DeptName, DeptName ?? "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.AppKey, AppKey ?? "")); return(userIdentity); }
/// <summary> /// Determines whether the specified Object is equal to the current Object. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (obj == null) { return(false); } if (Object.ReferenceEquals(this, obj)) { return(true); } if (this.GetType() != obj.GetType()) { return(false); } var other = (VLCredential)obj; //reference types if (!Object.Equals(LogOnToken, other.LogOnToken)) { return(false); } if (!Object.Equals(PswdToken, other.PswdToken)) { return(false); } if (!Object.Equals(PswdSalt, other.PswdSalt)) { return(false); } if (!Object.Equals(PswdQuestion, other.PswdQuestion)) { return(false); } if (!Object.Equals(PswdAnswer, other.PswdAnswer)) { return(false); } if (!Object.Equals(Comment, other.Comment)) { return(false); } //value types if (!CredentialId.Equals(other.CredentialId)) { return(false); } if (!Principal.Equals(other.Principal)) { return(false); } if (!PrincipalType.Equals(other.PrincipalType)) { return(false); } if (!PswdFormat.Equals(other.PswdFormat)) { return(false); } if (!IsApproved.Equals(other.IsApproved)) { return(false); } if (!IsLockedOut.Equals(other.IsLockedOut)) { return(false); } if (!LastLoginDate.Equals(other.LastLoginDate)) { return(false); } if (!LastPasswordChangedDate.Equals(other.LastPasswordChangedDate)) { return(false); } if (!LastLockoutDate.Equals(other.LastLockoutDate)) { return(false); } if (!FailedPasswordAttemptCount.Equals(other.FailedPasswordAttemptCount)) { return(false); } if (!FailedPasswordAttemptWindowStart.Equals(other.FailedPasswordAttemptWindowStart)) { return(false); } if (!FailedPasswordAnswerAttemptCount.Equals(other.FailedPasswordAnswerAttemptCount)) { return(false); } if (!FailedPasswordAnswerAttemptWindowStart.Equals(other.FailedPasswordAnswerAttemptWindowStart)) { return(false); } return(true); }