How to Add a Store Group to an Operation Programatically

Topics: General Topic
Nov 7, 2012 at 9:52 PM

I have an operation that I want to allow all DBUsers associated with a store group.

StoreGroup = "System Administrators"

Operation = "Operation1"

I see this is possible using the mmc snap in, but how do I accomplish the same programatically?

Thanks.

Coordinator
Nov 7, 2012 at 9:55 PM

Please explain better.

How do you do using the mmc snap in ?

Andrea Ferendeles / NetSqlAzMan Project Coordinator
Web / http://netsqlazman.codeplex.com
email aferende@hotmail.com

Da: lziegenhirt [email removed]
Inviato: mercoledì 7 novembre 2012 22:53
A: Andrea Ferendeles
Oggetto: How to Add a Store Group to an Operation Programatically [netsqlazman:402319]

From: lziegenhirt

I have an operation that I want to allow all DBUsers associated with a store group.

StoreGroup = "System Administrators"

Operation = "Operation1"

I see this is possible using the mmc snap in, but how do I accomplish the same programatically?

Thanks.


Le informazioni contenute in questa comunicazione e gli eventuali documenti allegati hanno carattere confidenziale e sono a uso esclusivo del destinatario. Nel caso questa comunicazione Vi sia pervenuta per errore, Vi informiamo che la sua diffusione e riproduzione è contraria alla legge e preghiamo di darci prontamente avviso e di cancellare quanto ricevuto. Grazie.

This e-mail message and any files transmitted with it contain confidential information intended only for the person(s) to whom it is addressed. If you are not the intended recipient, you are hereby notified that any use or distribution of this e-mail is strictly prohibited: please notify the sender and delete the original message. Thank you.

Nov 7, 2012 at 10:22 PM

I navigate to Operation Authorizations > I right click on Operation1 > I click Manage Authorizations

The dialog box gives me a button to choose store groups

I choose a store group from the list.

Hope this helps.

Thanks for the prompt reply.

Coordinator
Nov 8, 2012 at 5:39 AM

Hi,

this is the code snippet based on your needs:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Security.Principal;

using NetSqlAzMan;

using NetSqlAzMan.Interfaces;

namespace NetSqlAzManDemo

{

class Program

{

static void Main(string[] args)

{

string sqlConnectionString = "data source=(local);Initial Catalog=NetSqlAzManStorage;Integrated Security=SSPI";

using (IAzManStorage storage = new SqlAzManStorage(sqlConnectionString))

{

storage.OpenConnection();

storage.BeginTransaction();

try

{

IAzManStore store = storage.GetStore("My Store");

IAzManApplication application = store.GetApplication("My Application");

IAzManStoreGroup sgSystemAdministrators = store.GetStoreGroup("System Administrators");

IAzManItem operation1 = application.GetItem("Operation1");

IAzManAuthorization auth = operation1.CreateAuthorization(

new SqlAzManSID(WindowsIdentity.GetCurrent().User), WhereDefined.LDAP,

sgSystemAdministrators.SID, WhereDefined.Store,

AuthorizationType.Allow,

null, null);

storage.CommitTransaction();

}

catch

{

storage.RollBackTransaction();

}

}

}

}

}

Regards,

Andrea.

Andrea Ferendeles / NetSqlAzMan Project Coordinator
Web / http://netsqlazman.codeplex.com
email aferende@hotmail.com

Da: lziegenhirt [email removed]
Inviato: mercoledì 7 novembre 2012 23:23
A: Andrea Ferendeles
Oggetto: Re: How to Add a Store Group to an Operation Programatically [netsqlazman:402319]

From: lziegenhirt

I navigate to Operation Authorizations > I right click on Operation1 > I click Manage Authorizations

The dialog box gives me a button to choose store groups

I choose a store group from the list.

Hope this helps.

Thanks for the prompt reply.


Le informazioni contenute in questa comunicazione e gli eventuali documenti allegati hanno carattere confidenziale e sono a uso esclusivo del destinatario. Nel caso questa comunicazione Vi sia pervenuta per errore, Vi informiamo che la sua diffusione e riproduzione è contraria alla legge e preghiamo di darci prontamente avviso e di cancellare quanto ricevuto. Grazie.

This e-mail message and any files transmitted with it contain confidential information intended only for the person(s) to whom it is addressed. If you are not the intended recipient, you are hereby notified that any use or distribution of this e-mail is strictly prohibited: please notify the sender and delete the original message. Thank you.

Nov 8, 2012 at 1:03 PM

It worked, Thanks you.

From: aferende [email removed]
Sent: Thursday, November 08, 2012 12:40 AM
To: lziegenhirt@comcast.net
Subject: Re: How to Add a Store Group to an Operation Programatically [netsqlazman:402319]

From: aferende

Hi,

this is the code snippet based on your needs:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Security.Principal;

using NetSqlAzMan;

using NetSqlAzMan.Interfaces;

namespace NetSqlAzManDemo

{

class Program

{

static void Main(string[] args)

{

string sqlConnectionString = "data source=(local);Initial Catalog=NetSqlAzManStorage;Integrated Security=SSPI";

using (IAzManStorage storage = new SqlAzManStorage(sqlConnectionString))

{

storage.OpenConnection();

storage.BeginTransaction();

try

{

IAzManStore store = storage.GetStore("My Store");

IAzManApplication application = store.GetApplication("My Application");

IAzManStoreGroup sgSystemAdministrators = store.GetStoreGroup("System Administrators");

IAzManItem operation1 = application.GetItem("Operation1");

IAzManAuthorization auth = operation1.CreateAuthorization(

new SqlAzManSID(WindowsIdentity.GetCurrent().User), WhereDefined.LDAP,

sgSystemAdministrators.SID, WhereDefined.Store,

AuthorizationType.Allow,

null, null);

storage.CommitTransaction();

}

catch

{

storage.RollBackTransaction();

}

}

}

}

}

Regards,

Andrea.

Andrea Ferendeles / NetSqlAzMan Project Coordinator
Web / http://netsqlazman.codeplex.com
email aferende@hotmail.com

Da: lziegenhirt [email removed]
Inviato: mercoledì 7 novembre 2012 23:23
A: Andrea Ferendeles
Oggetto: Re: How to Add a Store Group to an Operation Programatically [netsqlazman:402319]

From: lziegenhirt

I navigate to Operation Authorizations > I right click on Operation1 > I click Manage Authorizations

The dialog box gives me a button to choose store groups

I choose a store group from the list.

Hope this helps.

Thanks for the prompt reply.


Le informazioni contenute in questa comunicazione e gli eventuali documenti allegati hanno carattere confidenziale e sono a uso esclusivo del destinatario. Nel caso questa comunicazione Vi sia pervenuta per errore, Vi informiamo che la sua diffusione e riproduzione è contraria alla legge e preghiamo di darci prontamente avviso e di cancellare quanto ricevuto. Grazie.

This e-mail message and any files transmitted with it contain confidential information intended only for the person(s) to whom it is addressed. If you are not the intended recipient, you are hereby notified that any use or distribution of this e-mail is strictly prohibited: please notify the sender and delete the original message. Thank you.