public CreateUserStatus CreateUser(RegistrationData user, [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))] [RegularExpression("^.*[^a-zA-Z0-9].*$", ErrorMessageResourceName = "ValidationErrorBadPasswordStrength", ErrorMessageResourceType = typeof(ValidationErrorResources))] [StringLength(50, MinimumLength = 7, ErrorMessageResourceName = "ValidationErrorBadPasswordLength", ErrorMessageResourceType = typeof(ValidationErrorResources))] string password) { if (user == null) { throw new ArgumentNullException("user"); } // Run this BEFORE creating the user to make sure roles are enabled and the default role // will be available // // If there are a problem with the role manager it is better to fail now than to have it // happening after the user is created if (!Roles.RoleExists(UserRegistrationService.DefaultRole)) { Roles.CreateRole(UserRegistrationService.DefaultRole); } // NOTE: ASP.NET by default uses SQL Server Express to create the user database. // CreateUser will fail if you do not have SQL Server Express installed. MembershipCreateStatus createStatus; Membership.CreateUser(user.UserName, password, user.Email, user.Question, user.Answer, true, null, out createStatus); if (createStatus != MembershipCreateStatus.Success) { return UserRegistrationService.ConvertStatus(createStatus); } // Assign it to the default role // This *can* fail but only if role management is disabled Roles.AddUserToRole(user.UserName, UserRegistrationService.DefaultRole); // Set its friendly name (profile setting) // This *can* fail but only if Web.config is configured incorrectly ProfileBase profile = ProfileBase.Create(user.UserName, true); profile.SetPropertyValue("FriendlyName", user.FriendlyName); profile.Save(); return CreateUserStatus.Success; }
/// <summary> /// Asynchronously invokes the 'CreateUser' method of the domain service. /// </summary> /// <param name="user">The value for the 'user' parameter of this action.</param> /// <param name="password">The value for the 'password' parameter of this action.</param> /// <returns>An operation instance that can be used to manage the asynchronous request.</returns> // Unable to generate the following attribute(s) for parameter 'password' due to the following error(s): // // - The attribute 'System.ComponentModel.DataAnnotations.RegularExpressionAttribute' references type 'UsingRIAServices.Web.Resources.ValidationErrorResources' that is not accessible in the client project 'UsingRIAServices.csproj'. Are you missing an assembly reference? // - The attribute 'System.ComponentModel.DataAnnotations.RegularExpressionAttribute' references a property 'ValidationErrorBadPasswordStrength' on type 'UsingRIAServices.Web.Resources.ValidationErrorResources' that is not accessible in the client project 'UsingRIAServices.csproj'. // [RegularExpressionAttribute("^.*[^a-zA-Z0-9].*$", ErrorMessageResourceName = "ValidationErrorBadPasswordStrength", ErrorMessageResourceType = typeof(UsingRIAServices.Web.Resources.ValidationErrorResources))] // // - The attribute 'System.ComponentModel.DataAnnotations.RequiredAttribute' references type 'UsingRIAServices.Web.Resources.ValidationErrorResources' that is not accessible in the client project 'UsingRIAServices.csproj'. Are you missing an assembly reference? // - The attribute 'System.ComponentModel.DataAnnotations.RequiredAttribute' references a property 'ValidationErrorRequiredField' on type 'UsingRIAServices.Web.Resources.ValidationErrorResources' that is not accessible in the client project 'UsingRIAServices.csproj'. // [RequiredAttribute(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(UsingRIAServices.Web.Resources.ValidationErrorResources))] // // - The attribute 'System.ComponentModel.DataAnnotations.StringLengthAttribute' references type 'UsingRIAServices.Web.Resources.ValidationErrorResources' that is not accessible in the client project 'UsingRIAServices.csproj'. Are you missing an assembly reference? // - The attribute 'System.ComponentModel.DataAnnotations.StringLengthAttribute' references a property 'ValidationErrorBadPasswordLength' on type 'UsingRIAServices.Web.Resources.ValidationErrorResources' that is not accessible in the client project 'UsingRIAServices.csproj'. // [StringLengthAttribute(50, ErrorMessageResourceName = "ValidationErrorBadPasswordLength", ErrorMessageResourceType = typeof(UsingRIAServices.Web.Resources.ValidationErrorResources), MinimumLength = 7)] // public InvokeOperation<CreateUserStatus> CreateUser(RegistrationData user, string password) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("user", user); parameters.Add("password", password); this.ValidateMethod("CreateUser", parameters); return ((InvokeOperation<CreateUserStatus>)(this.InvokeOperation("CreateUser", typeof(CreateUserStatus), parameters, true, null, null))); }
/// <summary> /// Asynchronously invokes the 'CreateUser' method of the domain service. /// </summary> /// <param name="user">The value for the 'user' parameter of this action.</param> /// <param name="password">The value for the 'password' parameter of this action.</param> /// <returns>An operation instance that can be used to manage the asynchronous request.</returns> public InvokeOperation<CreateUserStatus> CreateUser(RegistrationData user, [RegularExpression("^.*[^a-zA-Z0-9].*$", ErrorMessageResourceName="ValidationErrorBadPasswordStrength", ErrorMessageResourceType=typeof(ValidationErrorResources))] [Required(ErrorMessageResourceName="ValidationErrorRequiredField", ErrorMessageResourceType=typeof(ValidationErrorResources))] [StringLength(50, ErrorMessageResourceName="ValidationErrorBadPasswordLength", ErrorMessageResourceType=typeof(ValidationErrorResources), MinimumLength=7)] string password) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("user", user); parameters.Add("password", password); this.ValidateMethod("CreateUser", parameters); return ((InvokeOperation<CreateUserStatus>)(this.InvokeOperation("CreateUser", typeof(CreateUserStatus), parameters, true, null, null))); }