Users.GetUserByNameAsync
Description
Gets UserInfo details with specified User Name from the connected AI Command Center.
C#
Task<UserInfo> GetUserByNameAsync(string userName)
Properties
Input
| Property | Description |
|---|---|
| userName | Specify the name of the user to retrieve the information. |
Output
| Type | Description |
|---|---|
| Task<UserInfo> | Returns the information of a user using userName. |
Remarks
Use GetUserByNameAsync API to get the UserInfo details from the connected AI Command Center.
Example
C#
public async Task GetUserByNameAsync()
{
IControlRoomContext context = LoginControlRoom();
try
{
string userName = "user1";
UserInfo userInfo = await context.Users.GetUserByNameAsync(userName);
Console.WriteLine("User Id: " + userInfo.UserId);
}
finally
{
context.Close();
}
}
Connection helper
public IControlRoomContext LoginControlRoom()
{
string RequiredSetting(string name) => Environment.GetEnvironmentVariable(name) ?? throw new InvalidOperationException($"Set {name} before running this example.");
string serverUrl = RequiredSetting("INTELLIBUDDIES_SERVER_URL");
string userName = RequiredSetting("INTELLIBUDDIES_USERNAME");
string password = RequiredSetting("INTELLIBUDDIES_PASSWORD");
string connectionString = $"ServerUrl={serverUrl};UserName={userName};Password={password}";
IControlRoomContext context = new ControlRoomContext(connectionString);
context.Open();
return context;
}
See Get started for namespaces, configuration, and context cleanup, and SDK usage for error handling.