本文整理汇总了C#中MembershipCreateStatus类的典型用法代码示例。如果您正苦于以下问题:C# MembershipCreateStatus类的具体用法?C# MembershipCreateStatus怎么用?C# MembershipCreateStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MembershipCreateStatus类属于命名空间,在下文中一共展示了MembershipCreateStatus类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
Page.Validate();
if (Page.IsValid)
{
StockplayMembershipProvider provider = (StockplayMembershipProvider) Membership.Provider;
MembershipCreateStatus status = new MembershipCreateStatus();
provider.CreateUser(UserName.Text, Password.Text, Email.Text,
txtLastname.Text, txtFirstname.Text,- 1, out status);
if (status != MembershipCreateStatus.Success)
{
ErrorLabel.Visible = true;
}
else
{
ErrorLabel.Visible = false;
TableRegister.Visible = false;
FinishRegistration.Visible = true;
try
{
SendMail();
}
catch (Exception ex)
{
ILog sysLog = LogManager.GetLogger("Register");
sysLog.Error("Failed to send e-mail", ex);
}
}
}
}
}
开发者ID:maleadt,项目名称:stockplay,代码行数:35,代码来源:Register.aspx.cs
示例2: CreateUser
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
if (string.IsNullOrEmpty(username))
{
status = MembershipCreateStatus.InvalidUserName;
return null;
}
if (string.IsNullOrEmpty(password))
{
status = MembershipCreateStatus.InvalidPassword;
return null;
}
string hashedPassword = Crypto.HashPassword(password);
if (hashedPassword.Length > 128)
{
status = MembershipCreateStatus.InvalidPassword;
return null;
}
if (_userRepository.UserNameTaken(username))
{
status = MembershipCreateStatus.DuplicateUserName;
return null;
}
var newBorn = _userRepository.CreateUser(username, hashedPassword, email);
status = MembershipCreateStatus.Success;
//TODO: Schedule E-mail notification in case email is provided. Also set up a default user settings.
return new MembershipUser(System.Web.Security.Membership.Provider.Name, newBorn.UserName, newBorn.Id,
newBorn.Email, null, null, true, newBorn.IsLockedOut, newBorn.CreateDate.Value, newBorn.LastLoginDate.Value,
newBorn.LastActivityDate.Value, newBorn.LastPasswordChangedDate.Value, newBorn.LastLockoutDate.Value);
}
开发者ID:Excepti0n,项目名称:radacode.com,代码行数:35,代码来源:WebUserMembershipProvider.cs
示例3: CreateUser
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
if (!SecUtility.ValidateParameter(ref password, true, true, false, 0x80))
{
status = MembershipCreateStatus.InvalidPassword;
return null;
}
if (!SecUtility.ValidateParameter(ref username, true, true, true, 0x100))
{
status = MembershipCreateStatus.InvalidUserName;
return null;
}
if (!SecUtility.ValidateParameter(ref email, this.RequiresUniqueEmail, this.RequiresUniqueEmail, false, 0x100))
{
status = MembershipCreateStatus.InvalidEmail;
return null;
}
if (GetUser(username, false) != null)
{
status = MembershipCreateStatus.DuplicateUserName;
return null;
}
if (GetUserNameByEmail(email) != null)
{
status = MembershipCreateStatus.DuplicateUserName;
return null;
}
if (password.Length < this.MinRequiredPasswordLength)
{
status = MembershipCreateStatus.InvalidPassword;
return null;
}
int num = 0;
for (int i = 0; i < password.Length; i++)
{
if (!char.IsLetterOrDigit(password, i))
{
num++;
}
}
if (num < this.MinRequiredNonAlphanumericCharacters)
{
status = MembershipCreateStatus.InvalidPassword;
return null;
}
if ((this.PasswordStrengthRegularExpression.Length > 0) && !Regex.IsMatch(password, this.PasswordStrengthRegularExpression))
{
status = MembershipCreateStatus.InvalidPassword;
return null;
}
ValidatePasswordEventArgs e = new ValidatePasswordEventArgs(username, password, true);
this.OnValidatingPassword(e);
if (e.Cancel)
{
status = MembershipCreateStatus.InvalidPassword;
return null;
}
return CheckedCreateUser(username, password, email, passwordQuestion, passwordAnswer, isApproved, providerUserKey, out status);
}
开发者ID:eluxen,项目名称:RavenDBMembership,代码行数:60,代码来源:MembershipProviderValidated.cs
示例4: CreateUser
public override MembershipUser CreateUser(string firstName, string lastName, string username, string password, string email,
bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
var entities = new BdJobsEntities();
if (entities.Users.Any(u => u.UserName == username))
{
status = MembershipCreateStatus.DuplicateUserName;
}
else if (entities.Users.Any(u => u.Email == email))
{
status = MembershipCreateStatus.DuplicateEmail;
}
else
{
string hPassword = GetSHA1HashData(password);
var user = new User { UserName = username, Password = hPassword, RoleId = 3, FirstName = firstName, LastName = lastName, Email = email };
entities.Users.Add(user);
entities.SaveChanges();
status = MembershipCreateStatus.Success;
}
return null;
}
开发者ID:TheCompleteCode,项目名称:JobPortal,代码行数:26,代码来源:BdJobsMembershipProvider.cs
示例5: TestCustomerMemembershipProvider_CreateOneUser_Fail
public void TestCustomerMemembershipProvider_CreateOneUser_Fail()
{
MembershipCreateStatus status = new MembershipCreateStatus();
Assert.IsNull(provider.CreateUser("admin", "123456", "", "abc", "123", true, 4, out status));
Assert.AreEqual(status, MembershipCreateStatus.DuplicateUserName);
Assert.AreEqual(repository.UserInformations.Count(), 1);
}
开发者ID:ouyh18ctc,项目名称:Customers,代码行数:7,代码来源:TwoUsersMembershipProviderTest.cs
示例6: ErrorCodeToString
private static string ErrorCodeToString(MembershipCreateStatus createStatus)
{
string statusString = createStatus.ToString();
string resourceKey = "Exceptions.ErrorMessages.UserRegister.{0}".FormatWith(statusString);
return ResourceManager.GetString(resourceKey);
}
开发者ID:syil,项目名称:UrunYorum,代码行数:7,代码来源:AccountMembershipService.cs
示例7: ErrorCodeToString
private string ErrorCodeToString(MembershipCreateStatus status)
{
switch (status)
{
case MembershipCreateStatus.DuplicateUserName:
return "Username already exists. Please enter a different user name.";
case MembershipCreateStatus.DuplicateEmail:
return "A user name for that e-mail address already exists. Please enter a different e-mail address.";
case MembershipCreateStatus.InvalidPassword:
return "The password provided is invalid. Please enter a valid password value.";
case MembershipCreateStatus.InvalidEmail:
return "The e-mail address provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.InvalidUserName:
return "The user name provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.UserRejected:
return "The user creation request has been canceled. Please verify your entry and try again." +
"If the problem persists, please contact your system administrator.";
default:
return "An unknown error occurred. Please verify your entry and try again. If the problem persists, " +
"please contact your system administrator.";
}
}
开发者ID:johnfelipe,项目名称:EducationAdminManagementSystem,代码行数:28,代码来源:AccountController.cs
示例8: CreateUser
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
if (_dataService.IsExistingUsername(username))
{
status = MembershipCreateStatus.DuplicateUserName;
return null;
}
if (_dataService.IsExistingEmail(email))
{
status = MembershipCreateStatus.DuplicateEmail;
return null;
}
TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
string salt = SimpleHash.GetSalt(32);
string activationCode = ShortGuid.NewGuid();
User user = new User()
{
email = email,
usergroupid = 3,
username = username,
password = SimpleHash.MD5(password, salt),
passworddate = DateTime.Now.Date,
usertitle = "Guest",
joindate = Convert.ToInt32(ts.TotalSeconds),
timezoneoffset = -6,
options = 45108439,
salt = salt,
showbirthday = 0,
showvbcode = 0,
membergroupids = string.Empty
};
user = _dataService.CreateForumUser(user, activationCode);
if (user != null)
{
Login login = new Login();
login.Username = username;
login.Password = SimpleHash.MD5(password, salt);
login.Email = email;
login.ForumUserId = user.userid;
login.PasswordSalt = salt;
login = _dataService.CreateLogin(login);
if (login != null)
{
NtxfcMembershipProvider provider = Membership.Provider as NtxfcMembershipProvider;
provider.SendConfirmationEmail(username, email, String.Format("{0}/Account/Activation/?u={1}&i={2}", ConfigurationManager.AppSettings["MemberUrl"], HttpContext.Current.Server.UrlEncode(username), activationCode));
status = MembershipCreateStatus.Success;
return new MembershipUser(this.Name, username, login.Id, login.Email, string.Empty, string.Empty, true, false, new DateTime(), new DateTime(), new DateTime(), new DateTime(), new DateTime());
}
}
status = MembershipCreateStatus.ProviderError;
return null;
}
开发者ID:paulpetrov,项目名称:ntxfc.com,代码行数:60,代码来源:NtxfcMembershipProvider.cs
示例9: GetErrorMessage
public string GetErrorMessage(MembershipCreateStatus status)
{
switch (status)
{
case MembershipCreateStatus.DuplicateUserName:
return "Bu kullanıcı adı kullanılmakta,Başka bir kullanıcı adı deneyin";
case MembershipCreateStatus.DuplicateEmail:
return "Bu email kullanılmakta,Başka bir email deneyin";
case MembershipCreateStatus.InvalidPassword:
return "Geçersiz şifre";
case MembershipCreateStatus.InvalidEmail:
return "Geçersiz email";
case MembershipCreateStatus.InvalidUserName:
return "Geçersiz kullanıcı adı";
//case MembershipCreateStatus.InvalidAnswer:
// return "The password retrieval answer provided is invalid. Please check the value and try again.";
//case MembershipCreateStatus.InvalidQuestion:
// return "The password retrieval question provided is invalid. Please check the value and try again.";
//case MembershipCreateStatus.ProviderError:
// return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
//case MembershipCreateStatus.UserRejected:
// return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
default:
return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
}
}
开发者ID:haticenur,项目名称:CategoryProducts,代码行数:34,代码来源:Main.Master.cs
示例10: CreateUser
/// <summary>
/// 新しいメンバーシップユーザーをデータソースに追加します。
/// </summary>
/// <returns>
/// 新しく作成されたユーザーの情報が格納された <see cref="T:System.Web.Security.MembershipUser"/> オブジェクト。
/// </returns>
/// <param name="username">新しいユーザーのユーザー名。</param>
/// <param name="password">新しいユーザーのパスワード。</param>
/// <param name="email">新しいユーザーの電子メール アドレス。</param>
/// <param name="passwordQuestion">新しいユーザーのパスワードの質問。</param>
/// <param name="passwordAnswer">新しいユーザーのパスワードの解答。</param>
/// <param name="isApproved">新しいユーザーを承認するかどうか。</param>
/// <param name="providerUserKey">メンバーシップ データ ソースでのユーザーの一意の識別子。</param>
/// <param name="status">ユーザーが正常に作成されたかどうかを示す <see cref="T:System.Web.Security.MembershipCreateStatus"/> 列挙値。</param>
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
status = MembershipCreateStatus.ProviderError;
// パスワードの保護
var securePassword = new SecureString();
securePassword.AppendString(password);
// 認証の作成
var membership = new DomainModels.Membership(
new MembershipEntity
{
Name = username,
Password = securePassword,
});
var result = MembershipCreateStatus.ProviderError;
membership.Created += (sender, entity) => { result = MembershipCreateStatus.Success; };
membership.Create();
status = result;
var user = default (KandaMembershipUser);
membership.Found += (sender, entity) => { user = new KandaMembershipUser(entity); };
membership.Find();
return user;
}
开发者ID:kkkkkkaaaaaa,项目名称:kkkkkkaaaaaa,代码行数:40,代码来源:KandaMembershipProvider.cs
示例11: Authenticate
public MyTrelloUser Authenticate(string nickName, string password, out MembershipCreateStatus status)
{
var userModel = _repo.GetById(nickName);
if (userModel == null)
{
status = MembershipCreateStatus.InvalidUserName;
return null;
}
if(!userModel.IsValid)
{
status = MembershipCreateStatus.ProviderError;
return userModel;
}
IGenerator gen = new Generator();
if (!gen.GenerateHash(password).SequenceEqual(userModel.Password))
{
status = MembershipCreateStatus.InvalidPassword;
return null;
}
status = MembershipCreateStatus.Success;
return userModel;
}
开发者ID:ricardosousa1989,项目名称:MyTrello,代码行数:25,代码来源:MyTrelloAuthenticationProvider.cs
示例12: ErrorCodeToString
private static string ErrorCodeToString(MembershipCreateStatus createStatus)
{
// See http://msdn.microsoft.com/en-us/library/system.web.security.membershipcreatestatus.aspx for
// a full list of status codes and add appropriate error handling.
switch (createStatus)
{
case MembershipCreateStatus.DuplicateUserName:
return ClientCultureBasedResources.GetResource(() => ErrorResources.MembershipCreateStatusDuplicateUserName);
case MembershipCreateStatus.DuplicateEmail:
return ClientCultureBasedResources.GetResource(() => ErrorResources.MembershipCreateStatusDuplicateEmail);
case MembershipCreateStatus.ProviderError:
return ClientCultureBasedResources.GetResource(() => ErrorResources.MembershipCreateStatusProviderError);
case MembershipCreateStatus.UserRejected:
return ClientCultureBasedResources.GetResource(() => ErrorResources.MembershipCreateStatusUserRejected);
case MembershipCreateStatus.InvalidPassword:
case MembershipCreateStatus.InvalidEmail:
case MembershipCreateStatus.InvalidAnswer:
case MembershipCreateStatus.InvalidQuestion:
case MembershipCreateStatus.InvalidUserName:
// All this errors should have been handled by the UI validation so theoretically
// we should never get to this point
return "Validation Error: " + createStatus.ToString();
default:
return "Could not register the user, please verify the provided information and try again.";
}
}
开发者ID:jchynoweth,项目名称:TERSAppV2,代码行数:31,代码来源:UserRegistrationService.cs
示例13: ErrorMessage
public string ErrorMessage(MembershipCreateStatus status, out string field)
{
switch (status)
{
case MembershipCreateStatus.DuplicateUserName:
case MembershipCreateStatus.DuplicateEmail:
field = "userID";
return "The email is already being used";
case MembershipCreateStatus.InvalidPassword:
field = "password";
return "Invalid password";
case MembershipCreateStatus.InvalidEmail:
case MembershipCreateStatus.InvalidUserName:
field = "userID";
return "The email is invalid";
case MembershipCreateStatus.InvalidAnswer:
field = String.Empty;
return "The password retrieval answer provided is invalid";
case MembershipCreateStatus.InvalidQuestion:
field = String.Empty;
return "The password retrieval question provided is invalid";
case MembershipCreateStatus.ProviderError:
case MembershipCreateStatus.UserRejected:
default:
field = String.Empty;
return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
}
}
开发者ID:bwship,项目名称:athena-toolkit,代码行数:28,代码来源:ErrorMessageHelper.cs
示例14: CreateUser
public MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status, string name, string surname, string telephone, string country)
{
var args = new ValidatePasswordEventArgs(username, password, true);
OnValidatingPassword(args);
if (args.Cancel)
{
status = MembershipCreateStatus.InvalidPassword;
return null;
}
if (RequiresUniqueEmail && GetUserNameByEmail(email) != string.Empty)
{
status = MembershipCreateStatus.DuplicateEmail;
return null;
}
var user = GetUser(username, true);
if (user == null)
{
var userObj = new User { Username = username, Password = Assets.Encrypt(password), Email = email, Name = name, Surname = surname, Telephone = telephone };
new UserDa(databasecontext).Add(userObj);
status = MembershipCreateStatus.Success;
return GetUser(username, true);
}
status = MembershipCreateStatus.DuplicateUserName;
return null;
}
开发者ID:kudakwashegore,项目名称:Ndiringe,代码行数:33,代码来源:RueMembershipProvider.cs
示例15: CreateUser
/// <summary>
/// Adds a new user to the SQL Server membership database.
/// </summary>
/// <param name="username">The user name for the new user.</param>
/// <param name="password">The password for the new user.</param>
/// <param name="email">The e-mail address for the new user.</param>
/// <param name="passwordQuestion">The password question for the new user.</param>
/// <param name="passwordAnswer">The password answer for the new user.</param>
/// <param name="isApproved">Whether or not the new user is approved to be validated.</param>
/// <param name="providerUserKey">A <see cref="T:System.Guid"></see> that uniquely identifies the membership user in the SQL Server database.</param>
/// <param name="status">One of the <see cref="T:System.Web.Security.MembershipCreateStatus"></see> values, indicating whether the user was created successfully.</param>
/// <returns>
/// A <see cref="T:System.Web.Security.MembershipUser"></see> object for the newly created user. If no user was created, this method returns null.
/// </returns>
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
MembershipUser oldUser = base.CreateUser(username, password, email, passwordQuestion, passwordAnswer, isApproved, providerUserKey, out status);
if (status == MembershipCreateStatus.Success)
{
ProfileBase profile = ProfileBase.Create(oldUser.UserName);
string firstName = (string)profile.GetPropertyValue("FirstName");
string lastName = (string)profile.GetPropertyValue("LastName");
string displayName = (string)profile.GetPropertyValue("DisplayName");
CustomMembershipUser newUser = new CustomMembershipUser(oldUser.ProviderName,
oldUser.UserName,
oldUser.ProviderUserKey,
oldUser.Email,
oldUser.PasswordQuestion,
oldUser.Comment,
oldUser.IsApproved,
oldUser.IsLockedOut,
oldUser.CreationDate,
oldUser.LastLoginDate,
oldUser.LastActivityDate,
oldUser.LastPasswordChangedDate,
oldUser.LastLockoutDate,
displayName,
firstName,
lastName);
return newUser;
}
return null;
}
开发者ID:dineshkummarc,项目名称:BugNet,代码行数:45,代码来源:ExtendedSqlMembershipProvider.cs
示例16: CreateUser
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
ServerModel.User.Create(username, password, email);
var res = ServerModel.User.ByLogin(username);
status = res != null ? MembershipCreateStatus.Success : MembershipCreateStatus.UserRejected;
return res;
}
开发者ID:supermuk,项目名称:iudico,代码行数:7,代码来源:CustomMembershipProvider.cs
示例17: CreateUser
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion,
string passwordAnswer, bool isApproved, object providerUserKey,
out MembershipCreateStatus status)
{
status = MembershipCreateStatus.ProviderError;
return null;
}
开发者ID:pwhe23,项目名称:Myep,代码行数:7,代码来源:Membership.cs
示例18: MembershipProvider_Create_User
public void MembershipProvider_Create_User()
{
string username = Guid.NewGuid().ToString("N");
string password = Guid.NewGuid().ToString("N");
string email = Guid.NewGuid().ToString("N") + "@email.com";
string passwordQuestion = Guid.NewGuid().ToString("N");
string passwordAnswer = Guid.NewGuid().ToString("N");
bool isApproved = true;
MembershipCreateStatus status = new MembershipCreateStatus(); // TODO: Initialize to an appropriate value
var m = m_Provider.CreateUser(username, password, email, passwordQuestion, passwordAnswer, isApproved, null, out status);
Assert.AreEqual<MembershipCreateStatus>(MembershipCreateStatus.Success, status);
Assert.AreEqual<string>(email, m.Email);
var m1 = m_Provider.GetUser(m.ProviderUserKey, false);
Assert.AreEqual<string>(m.UserName, m1.UserName);
//delete the member
m_Provider.DeleteUser(username, true);
//make sure its gone
var hasException = false;
try
{
m_Provider.GetUser(m.ProviderUserKey, false);
}
catch (ArgumentException)
{
hasException = true;
}
Assert.IsTrue(hasException);
}
开发者ID:jracabado,项目名称:justEdit-,代码行数:34,代码来源:UmbracoMembershipProviderTest.cs
示例19: CreateAccount
//
// GET: /Account/
public string CreateAccount(string UserName, string Password, string Email, string securityQuestion, string AnswerSecurityQuestion)
{
System.Web.Security.MembershipCreateStatus UserCreated = new MembershipCreateStatus();
var a = Membership.CreateUser(UserName, Password, Email, securityQuestion, AnswerSecurityQuestion, true, out UserCreated);
switch (UserCreated)
{
case MembershipCreateStatus.DuplicateEmail:
{
return ("این ایمیل قبلا ثبت شده است");
}
case MembershipCreateStatus.DuplicateUserName:
{
return ("این نام کاربری قبلا انتخاب شده است");
}
case MembershipCreateStatus.Success:
{
return ("Success");
}
case MembershipCreateStatus.InvalidPassword:
{
return ("کلمه عبور معتبر نیست کلمه عبور حداقل باید 8 کاراکتر داشته باشد.");
}
default:
{
return ("به دلیل خطلای به وجود آمده ثبت نام انجام نشد");
}
}
}
开发者ID:TCRCompany,项目名称:Forum,代码行数:34,代码来源:AccountController.cs
示例20: CreateUser
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, password, true);
OnValidatingPassword(args);
if (args.Cancel)
{
status = MembershipCreateStatus.InvalidPassword;
return null;
}
if (RequiresUniqueEmail && GetUserNameByEmail(email) != "")
{
status = MembershipCreateStatus.DuplicateEmail;
return null;
}
MembershipUser u = GetUser(username, false);
if (u == null)
{
DBAuthRepository _user = new DBAuthRepository();
_user.CreateUser(username, password, email);
status = MembershipCreateStatus.Success;
return GetUser(username, false);
}
else
{
status = MembershipCreateStatus.DuplicateUserName;
}
return null;
}
开发者ID:lthomaz,项目名称:ASP.NET-MVC-Custom-Authentication,代码行数:32,代码来源:DBAuthMembershipProvider.cs
注:本文中的MembershipCreateStatus类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论