Reputation: 618
I have implemented windows authentication/authorization but I have to control the visibility of the GridView on the page as well for specific users.
How can I control this, Is there anyway we can maintain list of users(Domainname\username) in our web.config file and check through this list and give visibility of the GridView.
Note: I'm only allow to use web.config file and not allow to make use of local DB or any other XML file.
Upvotes: 0
Views: 134
Reputation: 795
I don't think there is a way to control visibility of particular control on the page built in ASP Membership Provider. You can set access for particular pages (file locations) for users and/or roles.
To achieve what you want create appSetting in web.config and set value to be comma separated list of users who can see the grid:
<add key="UsersWhoCanSeeGrid" value="user1,user2,user3"/>
Then on page load retrieve that value by key:
string users = ConfigurationManager.AppSettings["UsersWhoCanSeeGrid"];
And check if currently logged user is there:
bool showGrid = users.Split(",").Contains(User.Identity.Name);
then set Visible property of grid to be 'showGrid'
Upvotes: 3