Partager via


UserMgmtManager.AddUserAsync Method (String, PersonalInfo)

 

Asynchronously adds a new user account with the specified user name and personal information.

Namespace:   Microsoft.WindowsServerSolutions.Users
Assembly:  UserObjectModel (in UserObjectModel.dll)

Syntax

public void AddUserAsync(
    string userName,
    PersonalInfo info
)
public:
void AddUserAsync(
    String^ userName,
    PersonalInfo^ info
)
Public Sub AddUserAsync (
    userName As String,
    info As PersonalInfo
)

Parameters

Examples

The following code example shows how to asynchronously add a new user account:

UserMgmtManager userManager = new UserMgmtManager();
userManager.ConnectRequestCompletionCallback += 
   userManager_ConnectRequestCompletionCallback;
userManager.ConnectAsync();

The following code example shows the connect delegate method:

void userManager_ConnectRequestCompletionCallback(
   object sender, RequestCompletionEventArgs e)
{ 
   UserMgmtManager userManager = (UserMgmtManager)sender;
   userManager.ConnectRequestCompletionCallback -= 
      userManager_ConnectRequestCompletionCallback;
   userManager.AddUserRequestCompletionCallback += 
      userManager_AddUserRequestCompletionCallback;

   PersonalInfo pi = new PersonalInfo();
   pi.AccessLevel = AccessLevelType.Administrator;
   pi.FirstName = Resources.NetworkAdminFirstName;
   pi.LastName = string.Empty;
   pi.RemoteAccess = RemoteAccessType.Allowed;
   userManager.AddUserAsync("TestAccount", pi);
}

The following code example shows the add user delegate method:

void userManager_AddUserRequestCompletionCallback(
   object sender, AddUserRequestCompletionArgs e)
{
   UserMgmtManager userManager = (UserMgmtManager)sender;
   userManager.AddUserRequestCompletionCallback -= 
      userManager_AddUserRequestCompletionCallback;
   User user = e.User;
}

See Also

AddUserAsync Overload
UserMgmtManager Class
Microsoft.WindowsServerSolutions.Users Namespace

Return to top