private static bool CreateUser(string authToken, string userName, string password, string emailAddress, SimpleNameValueCollection profile, bool updateIfExists) { var service = new UserManagementServiceClient(); var result = service.CreateUser(authToken, userName, password, emailAddress, profile, updateIfExists); if (result.CallSuccess) return true; Console.WriteLine(result.FailureMessage); return false; }
public void CreateUser() { System.Console.WriteLine("---Create new user---"); System.Console.Write("IS:"); string IS = System.Console.ReadLine(); System.Console.Write("First Name:"); string firstName = System.Console.ReadLine(); System.Console.Write("Last Name:"); string lastName = System.Console.ReadLine(); System.Console.Write("Date of Birth (MM/DD/YYYY):"); DateTime dateOfBirth = DateTime.Parse(System.Console.ReadLine()); System.Console.Write("Salary:"); double salary = double.Parse(System.Console.ReadLine()); CreateUserRequest request = new CreateUserRequest { IS = IS, FirstName = firstName, LastName = lastName, DateOfBirth = dateOfBirth, Salary = salary }; CreateUserResponse response = null; response = _client.CreateUser(request); if (response == null) { System.Console.WriteLine("Error: Response is null"); } else if (!response.Success || response.UserId <= 0) { System.Console.WriteLine($"Error: { response.Message}"); } else { System.Console.WriteLine($"Success: User created, Id: {response.UserId}"); } System.Console.WriteLine("------------------"); }
/// <summary> /// Create a new user. /// Because no roles or permissions are explicitly set, the new user will have the "Report Viewer" and "Respondent" role. /// Additionally the new user will only be able to access public surveys and reports. /// </summary> /// <param name="authenticationToken">Encrypted forms auth token identifying the requesting user.</param> /// <param name="username">The new user's username.</param> /// <param name="password">The new user's password.</param> /// <param name="emailAddress">The new user's email address.</param> /// <param name="profileProperties">(Optional) A list of profile properties to associate with the user.</param> private static string CreateUser( string authenticationToken, string username, string password, string emailAddress, IList<KeyValuePair<string, string>> profileProperties = null) { /* * If you are unable to reference System.Service make sure that the project is configured to * use the full 4.0 framework and not the client profile. */ var proxy = new UserManagementServiceClient(); var profile = BuildProfile(profileProperties); var result = proxy.CreateUser( authenticationToken, username, password, emailAddress, profile, true); /* When true, if a user with the same name exists, update that user. */ // Handle exceptions if (!result.CallSuccess) { Console.WriteLine(result.FailureMessage); return null; } return result.ResultData; }
public void CreateUser(string id, string email, string userName) { using (UserManagementServiceClient proxy = new UserManagementServiceClient()) { proxy.CreateUser(id, email, userName); } }