Search Results for

    Show / Hide Table of Contents

    Global role identities

    Global role identity objects represents a user or group from the authentication system. They also contain information about which global role each identity has (if any).

    Querying for global role identities

    You can query a global role identity using the query method of the client. If you know the exact name of the identity to get, use the Identity property.

            var myIdentity = client.Query<GlobalRoleIdentity>()
    .Where(i => i.Identity == "MyUser").FirstOrDefault();
    

    If you only are interested in identities that has a specific global role, specify this using the Role property.

            var allCategoryAdmins = client.Query<GlobalRoleIdentity>()
    .Where(ua => ua.Roles == GlobalRoles.CategoryAdministrator)
    .ToList();
    

    You can combine these filters in any order as you like.

    Assigning roles to a global role identity

    To assign a role to a global role identity, first retrieve it and assign the desired roles to the Role property. Then call the store method to persist the changes.

             var identity = client.Query<GlobalRoleIdentity>()
    	.Single(i => i.Identity == "MyUser");
    identity.Roles = GlobalRoles.MediaFormatAdministrator | GlobalRoles.CategoryAdministrator;
    client.Store(identity);
    

    Name and Type are read only and cannot be changed since they are retrieved from the authentication system and not stored in ImageVault.

    Removing roles from a global role identity

    This can be done by assigning the Role property the GlobalRoles.None role and storing it.

             var identity2 = client.Query<GlobalRoleIdentity>()
    	.Single(i => i.Identity == "MyUser");
    identity2.Roles = GlobalRoles.None;
    client.Store(identity2);
    
    In This Article
    Back to top (c) Meriworks 2002-2022