Menu

Use SAS Token authentication

Andreas Menrath

Sample: Use SAS Token authentication

Overview

You can use the Cmdlets4Sas to connect to any server via SAS token authentication (the token authentication has to be configured in the SAS management console first). To learn more about token authentication see the official SAS documentation (link)

In this sample we will cover the following steps:

  • Authenticate to a remote SAS Metadata Server
  • Request a token login from the Metadata Server
  • Use the token to start a new Workspace Server session
  • Close the Workspaceserver session
  • Close the Metadata Server session

Code

# ensure module is loaded
if(!(Get-Module Cmdlets4Sas)) 
    {Import-Module Cmdlets4Sas}

# connect to SAS metadata server using IWA
$omi = Connect-SasMetadataServer "iom://mycompany.com:8561;Bridge;SECURITYPACKAGE=Negotiate"

# request one time login token from metadata server
$token = Get-SasMetaToken $omi

# use token as credentials to connect to a new SAS workspace server session
$ws = Connect-SasWorkspaceServer "iom://mycompany.com:8591;Bridge;" $token

# here you can do your stuff with the workspace, e.g. Read-SasLog $ws

# disconnect from workspace and metadata server
Disconnect-SasServer $ws
Disconnect-SasServer $omi

Related

Wiki: Samples