本文以 .NET SDK 为例,说明如何创建 RAM 用户。

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.Ram.Model.V20150501;

namespace ram_net_sdk_sample
{
    class Program
    {
        static void Main(string[] args)
        {
            // 构建一个阿里云 Client, 用于发起请求
            // 构建阿里云 Client 时需要设置 access key ID 和 access key secret
            // RAM 是 Global Service, API 入口位于华东 1 (杭州) , 这里 Region 填写:cn-hangzhou
            IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", "<access-key-id>", "<access-key-secret>");
            DefaultAcsClient client = new DefaultAcsClient(profile);


            // 构造 CreateUser 请求
            CreateUserRequest request = new CreateUserRequest();

            //设置参数: UserName
            request.UserName = "alice";

            // 发起请求,并得到 response
            try
            {
                CreateUserResponse response = client.GetAcsResponse(request);

                Console.WriteLine("UserName: " + response.User.UserName);
                Console.WriteLine("CreateTime: " + response.User.CreateDate);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            Console.ReadLine();
        }

    }
}