Amazon AWS SDK Guía de usuario Pagina 110

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 155
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 109
var iam = new IdentityManagementService();
try
{
var user = iam.GetUserByName("DemoUser");
var accessKey = user.CreateAccessKey();
Console.WriteLine("For user {0}:", user.Name);
Console.WriteLine(" Access key = {0}", accessKey.Id);
// This is the only time that the secret access key will be displayed.
Console.WriteLine(" Secret access key = {0}", accessKey.SecretAccessKey);
}
catch (NoSuchEntityException)
{
Console.WriteLine("User 'DemoUser' does not exist.");
}
catch (LimitExceededException)
{
Console.WriteLine("You can have only 2 access keys per user.");
}
Create a Login Profile for a User Account
The following example creates a login profile for a user account.
The following example doesn't use the AWS Resource APIs for .NET, as the resource APIs currently
don't support creating a login profile for a user account. However, this example is presented for
completeness:
// using Amazon.IdentityManagement;
// using Amazon.IdentityManagement.Model;
var client = new AmazonIdentityManagementServiceClient();
var request = new CreateLoginProfileRequest
{
UserName = "DemoUser",
Password = "ksdD9JHm",
PasswordResetRequired = true
};
try
{
client.CreateLoginProfile(request);
}
catch (NoSuchEntityException)
{
Console.WriteLine("User 'DemoUser' doesn't exist.");
}
Create an Instance Profile
The following example creates an instance profile.
The following example doesn't use the AWS Resource APIs for .NET, as the resource APIs currently
don't support creating an instance profile. However, this example is presented for completeness:
Version v2.0.0
106
AWS SDK for .NET Developer Guide
IAM Resource API Examples
Vista de pagina 109
1 2 ... 105 106 107 108 109 110 111 112 113 114 115 ... 154 155

Comentarios a estos manuales

Sin comentarios