MWCD
MWCD

Reputation: 103

How to list users from all Identity Domains in Oracle Cloud Infrastructure?

I need to retrieve a list of all users present in my Oracle Cloud environment via REST API or Go SDK.

Looking at the REST API docs, the Go SDK docs, and the OCI CLI docs, nowhere seems to provide an option to supply Identity Domain as an argument.

oci iam user list returns only the set of users present in the "Default" domain, even when I authenticate as a user in another domain.

Is there a way to fetch users from other Identity Domains?

Upvotes: 1

Views: 2792

Answers (3)

Imran Tahir
Imran Tahir

Reputation: 111

https://kaamilant.com/change-oracle-cloud-username/

you can use same API with get action and it will return list of all users from a single identity domain. if you have multiple identity domains, you can develop a script in postman to iterate one by one

Upvotes: 0

AT_S
AT_S

Reputation: 11

There is an oci-go-sdk with identity domain pkg which can used to list the users associated with a domain associated with a specific compartment.

https://github.com/oracle/oci-go-sdk/blob/master/identitydomains/list_users_request_response.go

Its requires domain url and the ListUserRequest. Below is the sample code.

package oci


import (
    "context"
    "fmt"
    "github.com/oracle/oci-go-sdk/example/helpers"
    "github.com/oracle/oci-go-sdk/v65/common"
    "github.com/oracle/oci-go-sdk/v65/identitydomains"
)

 
func InitializeConfigs1() common.ConfigurationProvider {
    customerTenancyId := "**********************" // root compartment ocid
    userOCID := "********************" // user coid
    homeRegion := "us-ashburn-1". // region
    fingerprint := "******************"
    key := "-----BEGIN PRIVATE KEY-----
*******************************
----END PRIVATE KEY-----"
    cp := common.NewRawConfigurationProvider(customerTenancyId, userOCID, homeRegion, fingerprint, key, nil)
    return cp
}
 
func ListDomainUsers() {
    cp := InitializeConfigs1()
    ExampleListUsers_ListUsers_IdentityDomain(cp)
}
 
func ExampleListUsers_ListUsers_IdentityDomain(cp common.ConfigurationProvider) {
    // build the url
    //endpoint := "https://****************" // Domain url
 
    client, err := identitydomains.NewIdentityDomainsClientWithConfigurationProvider(cp, endpoint)
 
    helpers.FatalIfError(err)
 
    // List domain users
    req := identitydomains.ListUsersRequest{}
    resp, err := client.ListUsers(context.Background(), req)
 
    helpers.FatalIfError(err)
 
    fmt.Println(resp)
 
    // list domain groups
    grpReq := identitydomains.ListGroupsRequest{}
    resp1, err1 := client.ListGroups(context.Background(), grpReq)
 
    helpers.FatalIfError(err1)
 
    fmt.Println(resp1)
}

Here is the bash documentation for reference. https://docs.oracle.com/en-us/iaas/tools/oci-cli/3.27.0/oci_cli_docs/cmdref/identity-domains/users/list.html

Upvotes: 0

Karthik Hegde
Karthik Hegde

Reputation: 136

Here is the REST API doc to list all users in the identity domain:

https://docs.oracle.com/en/cloud/paas/iam-domains-rest-api/op-admin-v1-users-get.html

Also, please use the domain URL for the API endpoint? Something like this: https://{domainUrl}/admin/v1/Users).

Unfortunately, we have Go SDK (or other SDKs and CLI) support only for IAM resources but not for Identity Domains (IDCS).

Thanks.

Upvotes: 1

Related Questions