943,602 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 664
  • C# RSS
Sep 18th, 2009
0

How can we assign or revok permission to users on apllications through C#.NET?

Expand Post »
How can we give permissions or revoke permissions on applications(i.e installed softwares) for a user via c#.net.
i have get the all uers list on the computer and also installed programs list but how can i change a user permissions in a way that he may not able to use some specific application like photoshop, corel draw.

Detailed Description of Problem
I have three users 'A' , 'B' and 'C' on my Computer (Standalone) . I want that Only User 'A' can use Photoshop and User 'B' can only use coreldraw. So how we can give permissions to User 'A' and 'B'. I want to do this programmaticaly through C#.NET.

please help me to solve this problem.

Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ashok90 is offline Offline
1 posts
since Sep 2009
Sep 18th, 2009
0

Re: How can we assign or revok permission to users on apllications through C#.NET?

Not sure how you would do that by registered application, but here is a good link/example code showing how to add/revoke privileges to particular directory for user. You could change it also to use the File class objects instead of the Directory objects if you desire. I know it's probably not exactly what you are looking for, but maybe a workaround if needed:

Security Access Control
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009
Sep 18th, 2009
0

Re: How can we assign or revok permission to users on apllications through C#.NET?

I can suggest to use AOP http://www.postsharp.org it helps very well...
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 18th, 2009
0

Re: How can we assign or revok permission to users on apllications through C#.NET?

I found this code, but havn't tried it. It shows how to revoke registry privilege for software application, and I think it might be more of what you are looking for.

C# Syntax (Toggle Plain Text)
  1.  
  2.  
  3. public static void RevokeRegKeyRights(RegistryKey regKey,
  4. NTAccount user,
  5. RegistryRights rightsFlags,
  6. InheritanceFlags inherFlags,
  7. PropagationFlags propFlags,
  8. AccessControlType actFlags)
  9. {
  10. RegistrySecurity regSecurity = regKey.GetAccessControl();
  11.  
  12. RegistryAccessRule rule = new RegistryAccessRule(user, rightsFlags, inherFlags,
  13. propFlags, actFlags);
  14. regSecurity.RemoveAccessRuleSpecific(rule);
  15.  
  16. regKey.SetAccessControl(regSecurity);
  17. }

I believe that if you call the above with the RegistryRights.ExecuteKey option, it should prevent that user from launching the application:

C# Syntax (Toggle Plain Text)
  1. NTAccount user = new NTAccount(@"WRKSTN\ST");
  2.  
  3. using (RegistryKey regKey = Registry.LocalMachine.OpenSubKey(
  4. @"SOFTWARE\MyCompany\MyApp"))
  5. {
  6. RevokeRegKeyRights(regKey, user, RegistryRights.ExecuteKey,
  7. InheritanceFlags.None, PropagationFlags.None,
  8. AccessControlType.Allow);
  9. }
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009
Sep 18th, 2009
0

Re: How can we assign or revok permission to users on apllications through C#.NET?

Sorry you need to apply permission on your developed application or another applications
In case of another applications, you may the one who has the administrative permission and when install log on the i.e. 'A' account and right click on the exe and run it as administrator enter your username and password and in installation progress say just for this user. (Just if the application supports that)
You need to disable some user permissions....
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 19th, 2009
0

Re: How can we assign or revok permission to users on apllications through C#.NET?

You need to block a pogram execution instead of setting/resetting permission.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: String formatting
Next Thread in C# Forum Timeline: Need Help in Regex?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC