Use DescribeUsers with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use DescribeUsers with an AWS SDK or CLI

The following code examples show how to use DescribeUsers.

CLI
AWS CLI

To retrieve details for specified users

This example retrieves details for all the users in the specified organization.

Command:

aws workdocs describe-users --organization-id d-926726012c

Output:

{ "Users": [ { "Id": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "Username": "example1User", "OrganizationId": "d-926726012c", "RootFolderId": "3c0e3f849dd20a9771d937b9bbcc97e18796150ae56c26d64a4fa0320a2dedc9", "RecycleBinFolderId": "c277f4c4d647be1f5147b3184ffa96e1e2bf708278b696cacba68ba13b91f4fe", "Status": "INACTIVE", "Type": "USER", "CreatedTimestamp": 1535478999.452, "ModifiedTimestamp": 1535478999.452 }, { "Id": "S-1-1-11-1111111111-2222222222-3333333333-4444&d-926726012c", "Username": "example2User", "EmailAddress": "example2User@site.awsapps.com", "GivenName": "example2Name", "Surname": "example2Surname", "OrganizationId": "d-926726012c", "RootFolderId": "35b886cb17198cbd547655e58b025dff0cf34aaed638be52009567e23dc67390", "RecycleBinFolderId": "9858c3e9ed4c2460dde9aadb4c69fde998070dd46e5e985bd08ec6169ea249ff", "Status": "ACTIVE", "Type": "MINIMALUSER", "CreatedTimestamp": 1535478836.584, "ModifiedTimestamp": 1535478836.584 } ] }
  • For API details, see DescribeUsers in AWS CLI Command Reference.

Ruby
SDK for Ruby
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

# Describes users within an organization # @param [String] org_id: The ID of the org. def describe_users(org_id) resp = @client.describe_users({ organization_id: org_id, include: 'ALL', # accepts ALL, ACTIVE_PENDING order: 'ASCENDING', # accepts ASCENDING, DESCENDING sort: 'USER_NAME', # accepts USER_NAME fields: %w[FULL_NAME STORAGE_LIMIT USER_STATUS STORAGE_USED] # Corrected field names }) resp.users.each do |user| @logger.info "First name: #{user.given_name}" @logger.info "Last name: #{user.surname}" @logger.info "Email: #{user.email_address}" @logger.info "Root folder: #{user.root_folder_id}" @logger.info '' end resp.users rescue Aws::WorkDocs::Errors::ServiceError => e @logger.error "AWS WorkDocs Service Error: #{e.message}" exit(1) end
  • For API details, see DescribeUsers in AWS SDK for Ruby API Reference.