IT:AD:NETSqlAzMan:HowTo:Check Authorization in Code
Summary
Notes
I'm furious that it has to be a WindowsIdentity. Makes it so unportable.
Process
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);