-
Notifications
You must be signed in to change notification settings - Fork 0
/
IdentityUsersExample.cs
71 lines (59 loc) · 2.14 KB
/
IdentityUsersExample.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using OCISDK.Core;
using OCISDK.Core.Common;
using OCISDK.Core.Identity;
using OCISDK.Core.Identity.Model;
using OCISDK.Core.Identity.Request;
using System;
using System.Collections.Generic;
using System.Text;
namespace Example
{
class IdentityUsersExample
{
public static void ConsoleDisplay(ClientConfig config)
{
var identityClient = new IdentityClient(config)
{
Region = Regions.US_ASHBURN_1
};
LoadOciUsers(identityClient);
Console.WriteLine("* Users------------------------");
var listUsersRequest = new ListUsersRequest()
{
CompartmentId = config.TenancyId
};
var users = identityClient.ListUsers(listUsersRequest).Items;
foreach (var user in users)
{
Console.WriteLine($" |-{user.Name}");
Console.WriteLine($" | providerId: {user.IdentityProviderId}");
Console.WriteLine($" | inactiveStatus: {user.InactiveStatus}");
Console.WriteLine($" | lifecycleState: {user.LifecycleState}");
Console.WriteLine($" | mfaActivated: {user.IsMfaActivated}");
Console.WriteLine($" | timeCreated: {user.TimeCreated}");
}
}
private static IEnumerable<UserDetails> OciUsers;
private static void LoadOciUsers(IdentityClient client)
{
OciUsers = GetOciUsers(client, null);
}
private static IEnumerable<UserDetails> GetOciUsers(IdentityClient client, string pageId)
{
var res = new List<UserDetails>();
var listUsersRequest = new ListUsersRequest()
{
CompartmentId = client.Config.TenancyId,
Page = pageId,
Limit = 2
};
var users = client.ListUsers(listUsersRequest);
res.AddRange(users.Items);
if (!string.IsNullOrEmpty(users.OpcNextPage))
{
res.AddRange(GetOciUsers(client, users.OpcNextPage));
}
return res;
}
}
}