Get Logged in User's Role

Oct 15, 2010 at 9:20 PM

Hi

I've started using latest version of NetSQLAzMan in my project. I want to get the list of a user is assigned to in the application store in my web application. Any pointers to  get the role list and related operations would be great.

Thanks in advance.

Smidha

 

 

Coordinator
Oct 15, 2010 at 10:19 PM

Hi,

get all the operation names … and for each one get related authorization User SID.

Then translate each User SID to the relative UserName.


Regards,

Andrea.

__________________________________
Andrea Ferendeles
NetSqlAzMan Project Coordinator
E-mail aferende@hotmail.com Web http://netsqlazman.codeplex.com

Oct 19, 2010 at 7:32 AM

Hi Aferende

Thanks for the reply. Is there a direct way than getting the list of operations and then related authorization UserSID. I'm a new to this, having some code will be helpful with the response.

Regards

Smidha

 

Coordinator
Oct 19, 2010 at 8:29 AM

Create a new Console Application and add NetSqlAzMan.dll reference:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using NetSqlAzMan;

using NetSqlAzMan.Interfaces;

using System.Security.Principal;

namespace ConsoleApplication2

{

class Program

{

static void Main(string[] args)

{

String cs = "Data Source=.;Initial Catalog=NetSqlAzManStorage;Integrated Security=SSPI";

using (IAzManStorage storage = new SqlAzManStorage(cs))

{

String storeName = "Here Your Store Name";

String applicationName = "Here Your Application Name";

IAzManApplication application = storage[storeName][applicationName];

foreach (IAzManApplicationGroup ag in application.GetApplicationGroups())

{

Console.WriteLine("Application Group: {0}", ag.Name);

foreach (IAzManApplicationGroupMember member in ag.GetApplicationGroupAllMembers())

{

Console.WriteLine("\tMember SID: {0}", member.SID.StringValue);

try

{

SecurityIdentifier userSID = new SecurityIdentifier(member.SID.StringValue);

NTAccount nta = (NTAccount)userSID.Translate(typeof(NTAccount));

String userName = nta.Value;

Console.WriteLine("\tMember Name: {0}", userName);

}

catch

{

Console.WriteLine("\tUnable to resolve SID to Username");

}

}

}

Console.WriteLine("Press any key to continue ...");

Console.ReadLine();

}

}

}

}

Regards,

Andrea.

__________________________________
Andrea Ferendeles
NetSqlAzMan Project Coordinator
E-mail aferende@hotmail.com Web http://netsqlazman.codeplex.com