ListGrantsForRoleAsync()

Lists the privileges granted to a role.

public async Task<ListGrantsForRoleResp> ListGrantsForRoleAsync(ListGrantsForRoleReq request, CancellationToken cancellationToken = default)

Request Syntax

var request = new ListGrantsForRoleReq
{
    RoleName = "read_only",
    DatabaseName = "default"
};

ListGrantsForRoleResp resp = await client.ListGrantsForRoleAsync(request);

REQUEST PARAMETERS:

  • RoleName (string) -

    The name of the role whose grants to list.

  • DatabaseName (string?) -

    The database to list the role’s grants in. When empty, the server resolves the default database.

RETURN TYPE:

Task

RETURNS:

A ListGrantsForRoleResp object that contains the privilege grants of the role.

ListGrantsForRoleResp
    Grants             // -> IReadOnlyList<GrantEntity>

PARAMETERS:

  • Grants (IReadOnlyList) -

    The privilege grants of the role. A GrantEntity that contains the following members:

    • RoleName (string) -

      The name of the role the privilege is granted to.

    • ObjectName (string) -

      The name of the object the privilege applies to.

    • ObjectType (string) -

      The type of the object the privilege applies to (e.g. Collection, Global).

    • DbName (string) -

      The database in which the object is defined.

    • Privilege (string) -

      The granted privilege (e.g. Search, Query, Insert).

    • Grantor (string) -

      The user who granted the privilege.

EXCEPTIONS:

  • MilvusException

    Thrown when the RPC fails or the server returns an error. Inspect the exception message for details.

Example

using Milvus.Client.V2;
using Milvus.Client.V2.Requests.Rbac;
using Milvus.Client.V2.Responses.Rbac;

using var client = new MilvusClientV2(new ConnectConfig
{
    Uri = "localhost:19530",
    Username = "root",
    Password = "Milvus"
});
await client.ConnectAsync();

ListGrantsForRoleResp resp = await client.ListGrantsForRoleAsync(new ListGrantsForRoleReq
{
    RoleName = "read_only"
});

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?