it:ad:netsqlazman:howto:check_authorization_in_code

IT:AD:NETSqlAzMan:HowTo:Check Authorization in Code

I'm furious that it has to be a WindowsIdentity. Makes it so unportable.

Check whether the current user perform the Operation as follows:

using NetSqlAzMan;
using NetSqlAzMan.Interfaces;



and then
//Connect to the store:
string connectionString =
    "Data Source=(local);Initial Catalog = NetSqlAzManStorage;Integrated Security = SSPI;";


IAzManStorage storage = new SqlAzManStorage(connectionString);



//Get an IIDentity
//Depending on the scenarion, Either this way:
WindowsIdentity identity = WindowsIdentity.GetCurrent();
//or this way:
identity = HttpContext.Current.Request.LogonUserIdentity;
//test it against an Operation:
AuthorizationType authorizationType = 
    storage.CheckAccess("Store1", "App1", "RetrieveInvoice", identity, DateTime.Now, true);
  • /home/skysigal/public_html/data/pages/it/ad/netsqlazman/howto/check_authorization_in_code.txt
  • Last modified: 2023/11/04 01:50
  • by 127.0.0.1