management roles with the WAT (Website Administration Tool) - ASP.NET 2.0 with ASP.NET AJAX This post will describe the use of WAT to manage and create roles for users, thanks to a question that arose in
http://www.forosdelweb.com on the subject.
First, create a new web site, to our project in the Solution Explorer add 3 new folders, named, User, Admin and Student and defaul.aspx page that is in the main directory (the web site created ) we add 3 LinkButtons to which they will change the Text property to the name of one of the folders you created .. so we have something like this (
NOTE: In Windows Vista we run our visual studio or the express version with administrator ):
After the menu "Web Site" go to "ASP.NET Configuration", where it will appear in our browser (use Firefox).
Now, let the Security tab, where we find it.
The only difference will be that the part that says existing functions will be 0, not 3 .. it is a little below me XD; keeping with the theme, we click where the red arrow points to open the security configuration wizard of the application, where we see something like this.
Ok, so now we will follow the wizard steps, this step will have to choose the access method of the application, in this case would be an Intranet or through Internet access, here is used through internet access.
Our next step of the wizard will serve to shape our data provider, in my case would sqlserver express (if so be that the application is currently configured for use: Advanced provider settings) .. if required otherwise we set it on the tab WAT provider (this is not covered here), so we will continue our step 4 .. here we decide whether our application will use roles or not .. so in this case obviously will qualify.
In this step we will add our roles, in this case we only need 3. Manager, Student, User; when we get to add roles we click Next
then be on the user creation step, for this example'll add two, one called crassr3cords which is then asiganara the administrator role, and July, which will not be anything , and therefore may not access what is in the Admin.
Step 6: here we will add our rules of access, for example "only users who are within the administrator role can access the files in the Admin" (with the WAT is so simple xD .. like magic ajajja ) here we stand in the camp assistants (in the directory tree that looks to the left), select who is going to apply the rule ( if we choose function are saying that this rule will apply to all users that belong to the role we choose, if we choose to let user apply the rule to a single user, for example a user with nick MRX, if we choose all user as deduction is taken for who is going to apply the rule if it chose anonymous users apply it to the users that are not authenticated or logged in), and then choose if you allow access to the directory you choose or deny it, we add rule and ready .. keep in mind that if for example I want to put it to the Admin folder can only enter the Manager role I make 2 rules, the first would have to say that user Allow Manager role or function to enter the Admin folder, and the second would have to say that all users Deny entry to this folder, thus, only the users, except those with Manager role will not be able to enter these files.
Finally after making the rules for our wallets (in this example only the first is told in the Admin deny all users, and edspues in the same folder there is another instruction, enabling administrators , so there is no problem in our hierarchy of permissions ..)
We just our security settings, now put to our user crassr3cords role or function within the "Administrator." security tab the WAT, we go where the red arrow points in our next picture.
Then we will see all registered users as shown in the image below, where we can manage that role or function belongs to (these translations are very bad XD), we will enroll crassr3cords.
After clicking on "edit" Select the box on the role to which it belongs, in this case Administrator and ready, we can close the WAT when reload the page.
Now, our project will add a page called login.aspx (at the directory), and it will add a Login control.
our browser will now create a page default.aspx solutions for the 3 folders that we had created, User, Admin and Student .. your solution explorer should look like mine xD.
Now, in the Default.aspx page of our website .. Home Page .. which is neither in Admin, Student or User, we give the path of our LinkButton PostBackUrl property to its proper default page (if the button with Text property as admin .. PostBackUrl be assigned to the Default page. aspx Admin folder and so on ...)
Now we run our Defaul.aspx and click on the link Admin.
This will lead to the login.aspx page as we are not yet logged in, so we log in !!!!! (Come at once with our manager).
By clicking on the login button this will take us to the default.aspx page of our admin folder (you can see clearly in the url that we are in the admin directory) .. so we'll see who will run our exercise.
Now, let's start a session as July (our user without permissions) obviously trying to enter our exclusive default.aspx page
administrators
As we shall see .. the application works we do not! xC. ajajaja. no lies .. perfect !!!.. This sends us back to log .. not let us go to our admin folder .. just what we wanted.
Well, obviously, tap links and therefore put more control to create users (CreateUserWizard), but the basics are this .. I hope to serve.