本文整理汇总了C#中System.Web.Security.MembershipUser类的典型用法代码示例。如果您正苦于以下问题:C# MembershipUser类的具体用法?C# MembershipUser怎么用?C# MembershipUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MembershipUser类属于System.Web.Security命名空间,在下文中一共展示了MembershipUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractPasswordData
public static Tuple<MembershipPasswordFormat, string, string> ExtractPasswordData(MembershipUser user)
{
MembershipPasswordFormat passwordFormat;
string passwordSalt;
string password;
ConnectionStringSettings connectionString = WebConfigurationManager.ConnectionStrings["DefaultConnection"];
using(SqlConnection conn = new SqlConnection(connectionString.ConnectionString))
{
using(SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "SELECT PasswordFormat, PasswordSalt, Password FROM aspnet_Membership WHERE [email protected]";
cmd.Parameters.AddWithValue("@UserId", user.ProviderUserKey);
conn.Open();
using(SqlDataReader rdr = cmd.ExecuteReader())
{
if(rdr != null && rdr.Read())
{
passwordFormat = (MembershipPasswordFormat) rdr.GetInt32(0);
passwordSalt = rdr.GetString(1);
password = rdr.GetString(2);
}
else
{
throw new Exception("Error extracting current password data from the database.");
}
}
}
}
return new Tuple<MembershipPasswordFormat, string, string>(passwordFormat, passwordSalt, password);
}
示例2: CreateUser
public override MembershipUser CreateUser(string username, string password, string email,
string passwordQuestion, string passwordAnswer, bool isApproved,
object providerUserKey, out MembershipCreateStatus status)
{
bool created = false;
MembershipUser membershipUser = null;
try
{
created = membershipRepository.Add(username, password, email, out providerUserKey);
membershipUser = new MembershipUser(this.Name, username, providerUserKey,
email, null, null, true, true,
DateTime.Today, DateTime.Today, DateTime.Today, DateTime.Today, DateTime.Today);
if (created)
{
status = MembershipCreateStatus.Success;
}
else
{
status = MembershipCreateStatus.UserRejected;
}
}
catch (Exception)
{
status = MembershipCreateStatus.DuplicateUserName;
}
return membershipUser;
}
示例3: Create
public ActionResult Create()
{
var Perfil = new PerfilUsuario();
MembershipUserCollection Users = Membership.GetAllUsers();
MembershipUser[] arr = new MembershipUser[Users.Count];
Users.CopyTo(arr, 0);
List<MembershipUser> Usuarios = arr.ToList();
List<PerfilUsuario> Perfiles = db.PerfilUsuarios.ToList();
foreach (var item in Perfiles)
{
Usuarios.Remove(Membership.GetUser(item.Username));
}
ViewBag.Usuarios = Usuarios;
var Sucursales = db.Sucursales.OrderBy(s => s.Nombre);
ViewBag.Sucursales = Sucursales;
return View(Perfil);
}
示例4: GetUser
public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
{
MembershipUser user = new MembershipUser("AgileMindProvider", "test", "test", "test",
string.Empty, string.Empty, true, false, DateTime.Now, DateTime.Now,
DateTime.Now, DateTime.Now, DateTime.Now);
return user;
}
示例5: UserAccount
public UserAccount(MembershipUser user)
{
UserName = user.UserName;
Email = user.Email;
PasswordQuestion = user.PasswordQuestion;
}
示例6: SendPasswordEmail
public static void SendPasswordEmail(MembershipUser user, string password, PasswordEmailType passwordEmailType)
{
assertExists(user);
assertHasEmail(user);
string body = passwordEmailTemplate.Replace("<%LoginName%>", user.UserName)
.Replace("<%Password%>", password);
body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-firstTime",
passwordEmailType == PasswordEmailType.FirstTime);
body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-reset",
passwordEmailType == PasswordEmailType.Reset);
body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-changedByUser",
passwordEmailType == PasswordEmailType.ChangedByUser);
body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-not-changedByUser",
passwordEmailType != PasswordEmailType.ChangedByUser);
MailMessage message = new MailMessage();
string testRecipients = ConfigurationManager.AppSettings.Get("TestEmailRecipients");
message.To.Add(testRecipients == null ? user.Email : testRecipients);
message.Subject = "Your new Total Giro password";
message.Body = body;
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Send(message);
}
示例7: User
public User(MembershipUser user)
{
this.UserName = user.UserName;
ProfileBase profile = ProfileBase.Create(user.UserName);
this.FullName = profile.GetPropertyValue("FullName") as string;
this.Email = user.Email;
}
示例8: UserProfileManager
public UserProfileManager(MembershipUser _user)
{
if (_user == null) {
throw new ArgumentNullException("_user");
}
UserProfile newProfile = new UserProfile(_user.UserName);
ProfileBase userProfile = ProfileBase.Create(_user.UserName);
ProfileGroupBase addressGroup = userProfile.GetProfileGroup("Address");
userProfile.Initialize(_user.UserName, true);
newProfile.Properties.Add(new ProfileProperty("Nome", "Name", userProfile["Name"].ToString()));
newProfile.Properties.Add(new ProfileProperty("Telefone", "Phone", addressGroup["Phone"].ToString()));
newProfile.Properties.Add(new ProfileProperty("CEP", "CEP", addressGroup["CEP"].ToString()));
newProfile.Properties.Add(new ProfileProperty("Endereço", "Street", addressGroup["Street"].ToString()));
newProfile.Properties.Add(new ProfileProperty("Bairro", "Area", addressGroup["Area"].ToString()));
newProfile.Properties.Add(new ProfileProperty("Estado", "State", addressGroup["State"].ToString()));
newProfile.Properties.Add(new ProfileProperty("Cidade", "City", addressGroup["City"].ToString()));
/*newProfile.Properties.Add(new ProfileProperty("FTP: Host", "FtpHost", ftpInfoGroup["FtpHost"].ToString()));
newProfile.Properties.Add(new ProfileProperty("FTP: Usuário", "FtpUserName", ftpInfoGroup["FtpUserName"].ToString()));
newProfile.Properties.Add(new ProfileProperty("FTP: Senha", "FtpPassword", ftpInfoGroup["FtpPassword"].ToString()));*/
this.UserProfile = newProfile;
}
示例9: User2UserViewModel
private UserViewModel User2UserViewModel(MembershipUser user)
{
var result = new UserViewModel {Name = user != null ? user.UserName : "Unknown user"};
if (user != null)
result.UserId = user.ProviderUserKey is Guid ? (Guid) user.ProviderUserKey : new Guid();
return result;
}
示例10: IsResetUrlValid
public bool IsResetUrlValid(string hash, out MembershipUser user)
{
user = null;
var isValid = false;
if (!string.IsNullOrEmpty(hash))
{
ResetPasswordModel link = _resetPasswordRespository.Find(hash);
isValid = (link != null && link.ExpireDate > DateTime.Now);
if (isValid)
{
user = Membership.Provider.GetUser(link.UserName, false);
if (user == null)
{
string userName = Membership.GetUserNameByEmail(link.UserName);
user = Membership.Provider.GetUser(userName, false);
}
if (user != null && user.IsLockedOut)
{
user.UnlockUser();
}
}
}
return isValid;
}
示例11: GetUser
public MembershipUser GetUser(String login)
{
using (RoleMembershipDataContext db = new RoleMembershipDataContext())
{
var result = from u in db.Users where (u.Login == login) select u;
if (result.Count() == 0)
{
return null;
}
User dbuser = result.FirstOrDefault();
MembershipUser user = new MembershipUser("CustomMembershipProvider",
dbuser.Login,
dbuser.UserId,
String.Empty,
String.Empty,
String.Empty,
true,
false,
dbuser.CreatedDate,
DateTime.Now,
DateTime.Now,
DateTime.Now,
DateTime.Now);
return user;
}
}
示例12: ChangePassword
public void ChangePassword(MembershipUser user, string newPassword)
{
throw new NotImplementedException();
//var resetPassword = user.ResetPassword();
//if(!user.ChangePassword(resetPassword, newPassword))
// throw new MembershipPasswordException("Could not change password.");
}
示例13: SetUpData
public void SetUpData()
{
// if the test user already exists delete it
Membership.DeleteUser("user1");
user = Membership.CreateUser("user1", "Password1!", "[email protected]");
}
示例14: EditEventViewModel
public EditEventViewModel(string eventId)
{
EventId = Int32.Parse(eventId);
_memUser = Membership.GetUser(HttpContext.Current.User.Identity.Name);
SiteUrl = HTTPUtils.GetFullyQualifiedApplicationPath() + "event/";
using (var context = new DataContext())
{
ThisEvent = context.Events.FirstOrDefault(x => x.EventId == EventId);
// Make sure we have a permalink set
if (String.IsNullOrEmpty(ThisEvent.PermaLink))
{
ThisEvent.PermaLink = ContentUtils.GetFormattedUrl(ThisEvent.Title);
}
EventCategories = context.EventCategories.Where(x => x.IsActive == true).ToList();
UsersSelectedCategories = new List<string>();
_thisUser = context.Users.FirstOrDefault(x => x.Username == _memUser.UserName);
}
// Get the admin modules that will be displayed to the user in each column
getAdminModules();
}
示例15: SetupData
public void SetupData()
{
// make sure the test user doesn't exist
Membership.DeleteUser("user1");
user = Membership.CreateUser("user1", "Password1!", "[email protected]");
}