ENS AuthorizationCreated

Jun 8, 2009 at 7:24 PM
Edited Jun 8, 2009 at 7:29 PM

Hi Andrea,

Is there any additional configuration steps that are required to enable ENS for use with a Database?

I create an Authorization via CreateAuthorization with the code below.

After that I can see a new Authorization in the Web Console, however the AuthorizationCreated event doesn't appear to fire.

SqlAzManENS ens; 

ens.AuthorizationCreated += new AuthorizationCreatedDelegate(SqlAzManENS_AuthorizationCreated);

protected void ButtonCreateAuthorization_Click(object sender, EventArgs e)

{

IAzManStorage storage = new SqlAzManStorage(cs);

storage.OpenConnection();

storage.BeginTransaction(AzManIsolationLevel.ReadUncommitted);

IAzManDBUser dbUser = storage.GetDBUser(userName);

IAzManSid userSID = dbUser.CustomSid;

IAzManStore store = storage.GetStore(

"Store");

IAzManApplication authApplication = store.GetApplication("MyApp");

IAzManItem item = authApplication.GetItem("Role1");

// Owner of authorization must exist.

IAzManAuthorization auth = item.CreateAuthorization(userSID, WhereDefined.Database, userSID, WhereDefined.Database, AuthorizationType.Allow, null, null);

storage.CommitTransaction();

storage.CloseConnection();

}

Regards, Bill 

 

 

Jun 8, 2009 at 10:17 PM

Hi bblaster,

SqlAzManENS ens;
ens.AuthorizationCreated += new AuthorizationCreatedDelegate(SqlAzManENS_AuthorizationCreated);

should raise a NullReferenceException. Only the NetSqlAzMan classes can (internal .cctor() ) create instances of the ENS (Event Notification System).

You must use the ENS property of your storage (that is automatically instantiated by the Storage itself):

Storage.ENS.AuthorizationCreated += new AuthorizationCreatedDelegate(SqlAzManENS_AuthorizationCreated);

Regards,

Andrea.

__________________________________
Andrea Ferendeles
NetSqlAzMan - Project Coordinator

http://netsqlazman.codeplex.com