Container for the parameters to the CreateUser operation.

Creates a new user for your AWS account.

For information about limitations on the number of users you can create, see Limitations on IAM Entities in Using AWS Identity and Access Management .

Inheritance: AmazonIdentityManagementServiceRequest
Ejemplo n.º 1
0
        private static void CreateUser()
        {
            Console.WriteLine("** Create User **");
            var iamClient = new AmazonIdentityManagementServiceClient();
            var request = new CreateUserRequest
            {
                UserName = "******",
                Path = @"/IT/architecture/"
            };

            var response = iamClient.CreateUser(request);

            Console.WriteLine("User Created");

        }
Ejemplo n.º 2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.IdentityManagement.Model.CreateUserRequest();

            if (cmdletContext.Path != null)
            {
                request.Path = cmdletContext.Path;
            }
            if (cmdletContext.PermissionsBoundary != null)
            {
                request.PermissionsBoundary = cmdletContext.PermissionsBoundary;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }
            if (cmdletContext.UserName != null)
            {
                request.UserName = cmdletContext.UserName;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
        protected override bool Execute(AmazonIdentityManagementService service)
        {
            Logger.LogMessage(MessageImportance.Normal, "Creating IAM User {0}", UserName);

            var request = new CreateUserRequest { UserName = UserName, Path = Path };
            CreateUserResponse response = service.CreateUser(request);

            if (response.CreateUserResult.User != null)
            {
                Arn = response.CreateUserResult.User.Arn;
                UserId = response.CreateUserResult.User.UserId;
                Logger.LogMessage(MessageImportance.Normal, "Created User with Arn: {0}", Arn);
                return true;
            }

            Logger.LogMessage(MessageImportance.Normal, "Failed to create User {0}", UserName);
            return false;
        }
 /// <summary>
 /// <para>Creates a new user for your AWS account.</para> <para>For information about limitations on the number of users you can create, see
 /// Limitations on IAM Entities in <i>Using AWS Identity and Access Management</i> .</para>
 /// </summary>
 /// 
 /// <param name="createUserRequest">Container for the necessary parameters to execute the CreateUser service method on
 ///          AmazonIdentityManagementService.</param>
 /// 
 /// <returns>The response from the CreateUser service method, as returned by AmazonIdentityManagementService.</returns>
 /// 
 /// <exception cref="NoSuchEntityException"/>
 /// <exception cref="LimitExceededException"/>
 /// <exception cref="EntityAlreadyExistsException"/>
 public CreateUserResponse CreateUser(CreateUserRequest createUserRequest)
 {
     IAsyncResult asyncResult = invokeCreateUser(createUserRequest, null, null, true);
     return EndCreateUser(asyncResult);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the CreateUser operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CreateUser operation on AmazonIdentityManagementServiceClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCreateUser
        ///         operation.</returns>
        public IAsyncResult BeginCreateUser(CreateUserRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new CreateUserRequestMarshaller();
            var unmarshaller = CreateUserResponseUnmarshaller.Instance;

            return BeginInvoke<CreateUserRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
Ejemplo n.º 6
0
 private Amazon.IdentityManagement.Model.CreateUserResponse CallAWSServiceOperation(IAmazonIdentityManagementService client, Amazon.IdentityManagement.Model.CreateUserRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Identity and Access Management", "CreateUser");
     try
     {
         #if DESKTOP
         return(client.CreateUser(request));
         #elif CORECLR
         return(client.CreateUserAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
 /// <summary>
 /// <para>Creates a new User for your AWS Account.</para> <para>For
 /// information about limitations on the number of Users you can create,
 /// see Limitations on IAM Entities in Using AWS Identity and Access
 /// Management.</para>
 /// </summary>
 /// 
 /// <param name="createUserRequest">Container for the necessary parameters
 ///           to execute the CreateUser service method on
 ///           AmazonIdentityManagementService.</param>
 /// 
 /// <returns>The response from the CreateUser service method, as returned
 ///         by AmazonIdentityManagementService.</returns>
 /// 
 /// <exception cref="NoSuchEntityException"/>
 /// <exception cref="LimitExceededException"/>
 /// <exception cref="EntityAlreadyExistsException"/>
 public CreateUserResponse CreateUser(CreateUserRequest createUserRequest)
 {
     IRequest<CreateUserRequest> request = new CreateUserRequestMarshaller().Marshall(createUserRequest);
     CreateUserResponse response = Invoke<CreateUserRequest, CreateUserResponse> (request, this.signer, CreateUserResponseUnmarshaller.GetInstance());
     return response;
 }
        internal CreateUserResponse CreateUser(CreateUserRequest request)
        {
            var marshaller = new CreateUserRequestMarshaller();
            var unmarshaller = CreateUserResponseUnmarshaller.Instance;

            return Invoke<CreateUserRequest,CreateUserResponse>(request, marshaller, unmarshaller);
        }
        /// <summary>
        /// <para>Creates a new user for your AWS account.</para> <para>For information about limitations on the number of users you can create, see <a href="http://docs.aws.amazon.com/IAM/latest/UserGuide/index.html?LimitationsOnEntities.html">Limitations on IAM Entities</a> in <i>Using
        /// AWS Identity and Access Management</i> .</para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CreateUser service method on
        /// AmazonIdentityManagementService.</param>
        /// 
        /// <returns>The response from the CreateUser service method, as returned by AmazonIdentityManagementService.</returns>
        /// 
        /// <exception cref="T:Amazon.IdentityManagement.Model.NoSuchEntityException" />
        /// <exception cref="T:Amazon.IdentityManagement.Model.LimitExceededException" />
        /// <exception cref="T:Amazon.IdentityManagement.Model.EntityAlreadyExistsException" />
		public CreateUserResponse CreateUser(CreateUserRequest request)
        {
            var task = CreateUserAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
        public override async Task<Resource> Create(
            Resource resource, 
            string correlationIdentifier)
        {
            if (null == resource)
            {
                throw new ArgumentNullException(AmazonWebServicesProvider.ArgumentNameResource);
            }

            if (string.IsNullOrWhiteSpace(correlationIdentifier))
            {
                throw new ArgumentNullException(AmazonWebServicesProvider.ArgumentNameCorrelationIdentifier);
            }

            if (string.IsNullOrWhiteSpace(resource.Identifier))
            {
                throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidResource);
            }

            string informationStarting =
                string.Format(
                    CultureInfo.InvariantCulture,
                    AmazonProvisioningAgentResources.InformationCreating,
                    resource.Identifier);
            ProvisioningAgentMonitor.Instance.Inform(informationStarting, true, correlationIdentifier);

            IAmazonIdentityManagementService proxy = null;
            try
            {
                proxy = AWSClientFactory.CreateAmazonIdentityManagementServiceClient(this.credentials);

                WindowsAzureActiveDirectoryGroup group = resource as WindowsAzureActiveDirectoryGroup;
                if (group != null)
                {
                    CreateGroupRequest request = new CreateGroupRequest(group.ExternalIdentifier);
                    CreateGroupResult response = await proxy.CreateGroupAsync(request);
                    group.Identifier = this.AnchoringBehavior.Identify(response.Group);

                    if (group.Members != null && group.Members.Any())
                    {
                        await this.AddMembers(group.ExternalIdentifier, group.Members, proxy, correlationIdentifier);
                    }

                    return group;
                }

                UserBase user = resource as UserBase;
                if (user != null)
                {
                    CreateUserRequest request = new CreateUserRequest(user.ExternalIdentifier);
                    CreateUserResult response = await proxy.CreateUserAsync(request);
                    user.Identifier = this.AnchoringBehavior.Identify(response.User);
                    return user;
                }

                string unsupportedSchema =
                            string.Join(
                                Environment.NewLine,
                                resource.Schemas);
                throw new NotSupportedException(unsupportedSchema);
            }
            finally
            {
                if (proxy != null)
                {
                    proxy.Dispose();
                    proxy = null;
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// <para>Creates a new user for your AWS account.</para> <para>For information about limitations on the number of users you can create, see <a href="http://docs.aws.amazon.com/IAM/latest/UserGuide/index.html?LimitationsOnEntities.html">Limitations on IAM Entities</a> in <i>Using
        /// AWS Identity and Access Management</i> .</para>
        /// </summary>
        /// 
        /// <param name="createUserRequest">Container for the necessary parameters to execute the CreateUser service method on
        /// AmazonIdentityManagementService.</param>
        /// 
        /// <returns>The response from the CreateUser service method, as returned by AmazonIdentityManagementService.</returns>
        /// 
        /// <exception cref="T:Amazon.IdentityManagement.Model.NoSuchEntityException" />
        /// <exception cref="T:Amazon.IdentityManagement.Model.LimitExceededException" />
        /// <exception cref="T:Amazon.IdentityManagement.Model.EntityAlreadyExistsException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<CreateUserResponse> CreateUserAsync(CreateUserRequest createUserRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CreateUserRequestMarshaller();
            var unmarshaller = CreateUserResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, CreateUserRequest, CreateUserResponse>(createUserRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
Ejemplo n.º 12
0
		internal CreateUserResponse CreateUser(CreateUserRequest request)
        {
            var task = CreateUserAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
        IAsyncResult invokeCreateUser(CreateUserRequest request, AsyncCallback callback, object state, bool synchronized)
        {
            var marshaller = new CreateUserRequestMarshaller();
            var unmarshaller = CreateUserResponseUnmarshaller.Instance;

            return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Just playing with this for now.
        /// </summary>
        /// <param name="aprofile"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public string CreateIAMAccount(string aprofile, string username, string password)
        {
            string IRReturning = "Yop";
            var credential = new Amazon.Runtime.StoredProfileAWSCredentials(aprofile);
            var iam = new AmazonIdentityManagementServiceClient(credential);

            CreateUserRequest request = new CreateUserRequest();
            request.UserName = username;

            var repo = iam.CreateUser(request);
            var det = repo.ResponseMetadata;

            CreateAccessKeyRequest KeyRequest = new CreateAccessKeyRequest();
            KeyRequest.UserName = username;




            return IRReturning;
        }
 IAsyncResult invokeCreateUser(CreateUserRequest createUserRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new CreateUserRequestMarshaller().Marshall(createUserRequest);
     var unmarshaller = CreateUserResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
 /// <summary>
 /// Initiates the asynchronous execution of the CreateUser operation.
 /// <seealso cref="Amazon.IdentityManagement.AmazonIdentityManagementService.CreateUser"/>
 /// </summary>
 /// 
 /// <param name="createUserRequest">Container for the necessary parameters to execute the CreateUser operation on
 ///          AmazonIdentityManagementService.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// 
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCreateUser
 ///         operation.</returns>
 public IAsyncResult BeginCreateUser(CreateUserRequest createUserRequest, AsyncCallback callback, object state)
 {
     return invokeCreateUser(createUserRequest, callback, state, false);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the CreateUser operation.
        /// <seealso cref="Amazon.IdentityManagement.IAmazonIdentityManagementService.CreateUser"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CreateUser operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
		public async Task<CreateUserResponse> CreateUserAsync(CreateUserRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CreateUserRequestMarshaller();
            var unmarshaller = CreateUserResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, CreateUserRequest, CreateUserResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
        /// <summary>
        /// Initiates the asynchronous execution of the CreateUser operation.
        /// <seealso cref="Amazon.IdentityManagement.IAmazonIdentityManagementService"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CreateUser operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<CreateUserResponse> CreateUserAsync(CreateUserRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CreateUserRequestMarshaller();
            var unmarshaller = CreateUserResponseUnmarshaller.Instance;

            return InvokeAsync<CreateUserRequest,CreateUserResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
 /// <summary>
 /// Initiates the asynchronous execution of the CreateUser operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the CreateUser operation on AmazonIdentityManagementServiceClient.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public void CreateUserAsync(CreateUserRequest request, AmazonServiceCallback<CreateUserRequest, CreateUserResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new CreateUserRequestMarshaller();
     var unmarshaller = CreateUserResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<CreateUserRequest,CreateUserResponse> responseObject 
                     = new AmazonServiceResult<CreateUserRequest,CreateUserResponse>((CreateUserRequest)req, (CreateUserResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<CreateUserRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }