IAccountTokenOps

The IAccountTokenOps interface is used to manage REST API access tokens.

All account objects in Adaxes implement the IAccountTokenOps interface. To use this interface, you need to bind to a directory object for which you want to generate, view, or delete tokens.

 How
PowerShell
Import-Module Adaxes

# Connect to the Adaxes service.
$ns = New-Object("Softerra.Adaxes.Adsi.AdmNamespace")
$service = $ns.GetServiceDirectly("localhost")

# Bind to a user.
$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Create new token.
$tokenValue = $user.CreateToken("My token", $null, $null)
C#
using System;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.AccessControl;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        // Connect to the Adaxes service.
        AdmNamespace ns = new AdmNamespace();
        IAdmService service = ns.GetServiceDirectly("localhost");

        // Bind to a user.
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";
        IAccountTokenOps user = 
            (IAccountTokenOps)service.OpenObject(userPath, null, null, 0);

        // Create new token.
        string tokenValue = user.CreateToken("My token", null, null);
    }
}

The credentials that you use to bind to an account matter. You must bind to an account with the credentials of that account or the credentials of an Adaxes service administrator to have sufficient permissions to manage access tokens.

Inheritance: IUnknown

Methods

Details

CreateToken()

Creates an access token for the bound account.

string CreateToken(string name, string description, DateTime? expiresAt)

Parameters

  • name – the token name.
  • description – the token description.
  • expiresAt – an optional parameter that defines the token expiration date. If set to null, the token will never expire.

Return value

The method returns the string value of the access token. Securely store the token value, as this is the only time it is displayed.

Remarks

An account can have multiple tokens, but each token name must be unique. Duplicate token names for different accounts are allowed.


GetToken()

Retrieves a specific access token for the bound account.

AccountToken GetToken(string name)

Parameters

  • name – the name of the token to retrieve.

GetAllTokens()

Retrieves all access tokens for the bound account.

AccountToken[] GetAllTokens()

DeleteToken()

Retrieves a specific access token for the bound account.

void DeleteToken(string name)

Parameters

  • name – the name of the token to delete.

DeleteAllTokens()

Deletes all access tokens for the bound account.

AccountToken[] DeleteAllTokens()

Requirements

Minimum required version: 2026.1

See also