skipcheck

TM1 client · Docs · Security

UserService

using Skipcheck.Tm1.Client.Services;

Users: /Users, the session's own user, their groups, and disconnecting them.

Group membership is set whole, with SetGroupsAsync: binding Groups in a user PATCH replaces them. TM1 (11.8) has no safe way to leave one group: a DELETE Users('u')/Groups('g')/$ref, which OData means as "remove the link", deletes the group, for everyone. This service never sends it.

Create a user in some groups, binding them by path:

// A user in two existing groups, bound by their paths
var groups = ODataPath.Of("Groups");
return await tm1.Users.CreateAsync(
    UserPatch.Builder().Name("alice").Password("initial-password").BindGroups(groups.Key("Planners"), groups.Key("Sales")).Build()
);

Take a user out of one group by setting the rest:

// Groups are set whole: keep every group but Planners
var rest = await tm1
    .Users.GroupsAsync("alice", ODataQuery.None().Select(Group.Fields.Name))
    .Select(group => group.Name!)
    .Where(group => group != "Planners")
    .ToListAsync();
await tm1.Users.SetGroupsAsync("alice", rest);

Lock a user out: disable them, then close their sessions.

// Stop the user logging in, then end the sessions they already have
await tm1.Users.UpdateAsync("alice", UserPatch.Builder().Enabled(false).Build());
await tm1.Users.DisconnectAsync("alice");

Members

UserService constructorA service that sends its requests through session.
ListAsyncGET Users, streamed.
GetAsyncGET Users('name').
ActiveUserAsyncThe user this session is for.
CreateAsyncCreates a user, in the groups the patch binds (UserPatch.PatchBuilder.BindGroups).
UpdateAsyncChanges the properties the patch sets, such as Password or Enabled.
SetGroupsAsyncPATCH Users('name') binding Groups.
DeleteAsyncDELETE Users('name').
GroupsAsyncGET Users('name')/Groups, streamed.
SessionsAsyncGET Users('name')/Sessions, streamed.
DisconnectAsyncCloses every session the user has.

UserService

constructor
UserService(Tm1Session session)

A service that sends its requests through session.

ListAsync

IAsyncEnumerable<User> ListAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)

GET Users, streamed.

TM1 REST EntitySet Users

GetAsync

Task<User> GetAsync(string name, ODataQuery? query = null, CancellationToken cancellationToken = default)

GET Users('name'). User names match ignoring case and spaces. A Tm1NotFoundException if there's none.

TM1 REST EntitySet Users

ActiveUserAsync

Task<User> ActiveUserAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)

GET ActiveUser: the user this session is for.

TM1 REST Singleton ActiveUser

CreateAsync

Task<User> CreateAsync(UserPatch user, CancellationToken cancellationToken = default)

POST Users: creates a user, in the groups the patch binds (UserPatch.PatchBuilder.BindGroups). It needs a name, and a password for Basic security.

TM1 REST EntitySet Users

UpdateAsync

Task UpdateAsync(string name, UserPatch patch, CancellationToken cancellationToken = default)

PATCH Users('name'): changes the properties the patch sets, such as Password or Enabled. TM1 (11.8) sends no ETag for a user, so there's no If-Match form. A patch that sets or binds Groups, which replaces them, is refused with an ArgumentException: use SetGroupsAsync.

TM1 REST EntitySet Users

SetGroupsAsync

Task SetGroupsAsync(string name, IReadOnlyList<string> groups, CancellationToken cancellationToken = default)

PATCH Users('name') binding Groups: makes the user's groups exactly groups, leaving any not listed.

TM1 REST EntitySet Users Navigation User/Groups

DeleteAsync

Task DeleteAsync(string name, CancellationToken cancellationToken = default)

DELETE Users('name').

TM1 REST EntitySet Users

GroupsAsync

IAsyncEnumerable<Group> GroupsAsync(string name, ODataQuery? query = null, CancellationToken cancellationToken = default)

GET Users('name')/Groups, streamed.

TM1 REST Navigation User/Groups

SessionsAsync

IAsyncEnumerable<ServerSession> SessionsAsync(string name, ODataQuery? query = null, CancellationToken cancellationToken = default)

GET Users('name')/Sessions, streamed: the user's sessions on the server.

TM1 REST Navigation User/Sessions

DisconnectAsync

Task DisconnectAsync(string name, CancellationToken cancellationToken = default)

tm1.Disconnect: closes every session the user has. Needs schema 10.2.2.6.

TM1 REST Action User/Disconnect