in asp.net mvc, if u create a simple site, some security code will be inserted automatically and role base security (via attributes) can be applyed to site (u can define roles in web configuration), but i have a windows application and i want to apply this role base autherization and authentication in my application on my methods and ... , i can write my own code to do this (attribute base), but is there any flexible component to do this as asp.net mvc in windows applications? I'm using vs 2010. any suggestion?
+1
A:
In a multi-user Windows application you would typically use Windows based authentication as it is built into Windows (assuming the software runs on a Windows network with a domain controller). Since the user is already logged into a Windows network, why have them log in again?
Setup Active Directory Groups for each Role in your application, and assign Users to those Groups as required. Then use System.DirectoryServices namespace to check whether the current user is a member of a Group/Role in your code. Then you can conditionally enable/disable features based on the user's Role.
For a code example, see: http://stackoverflow.com/questions/1032351/how-to-write-ldap-query-to-test-if-user-is-member-of-a-group
saille
2010-10-04 03:26:44