Exemple #1
0
        /// <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());
        }
Exemple #2
0
        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);
        }