Help needed in Web.config

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Help needed in Web.config

    Hi,

    My query.

    I need to restrict invalid users of my **database**

    I did..

    i am creating an asp.net app in c#.net . some part of my websites
    including the home page can be seen by any people . so that i checked
    the anonymous users check box and removed all other authentications in
    my directory settings of the virtual dir.

    my web.config file has

    for example , i want to restrict the user sa from accessing the
    database. i did
    ------------------------------------------------------------------------
    -------------
    <authentication mode="Forms">
    <forms loginUrl="webform1.aspx" name=".aspauth"/>
    </authentication>
    <authorization>
    <deny users="sa" />
    </authorization>
    * no impersonation
    ------------------------------------------------------------------------
    -------------
    *If i run the app,

    the default startup page will be "webform1.aspx" .on that form ,i 've a
    command but which opens the connection.It opens the connection
    eventhough the user id=sa;

    What should i do, to restrict the user "sa"

    Thanks in advance ,
    Raghu








    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Raghu Raman Guest

  2. Similar Questions and Discussions

    1. Error loading XML file c:\windows\microsoft.net\framework\v1.0.3705\Config\machine.config
      I had many ASP.NET web applications that I created before I had to rebuild my machine. After a fresh install of XP Pro, VS.NET 2003, etc, I now...
    2. Web References how to config to read URL from config?
      It's great that VS.NET makes it so effortless to add a web reference to a web service. The problem is, I haven't figured out a way to configure the...
    3. web.config vs machine.config ?
      1. I got this following error: ******************** Configuration Error Description: An error occurred during the processing of a...
    4. config file: a) what Module ? b) conditionals in config (for multiple hosts)
      Hi, a) I am looking for a module to handle config files. There are a number of these modules, like AppCconig. Any consensus about The Right...
    5. [RCR] Include CONFIG::Config['rubydocdir'] in rbconfig.rb
      Hi folks, I apologise if people have read this RCR and are not interested, but this is what I consider to be an important RCR, not a merely...
  3. #2

    Default RE: Help needed in Web.config

    Hi,

    I really couldn't get what you are trying to do with a "command which opens
    a connection" and forms authentication.

    If you want to restrict the users, you can do it at the page level, say you
    want to restrict "sa" to access the page webform1.aspx, you can do that.

    Your initial requirement was to protect some pages and other pages are open
    to everyone, if you want to restrict a specific page or pages you can use the
    location path tag as follows:-

    <location path="ProtectedPage.aspx">
    <system.web>
    <authorization>
    <deny users="?" />
    <deny users="sa" />
    </authorization>
    </system.web>
    </location>

    Or, if you have a bunch of pages, put them in a folder and put location
    path="foldername" to restrict unauthorised users for the entire pages in that
    folder.

    If you still want to show the page and check whether the user is logged in
    or he is "sa" on a button click, you need to write code for that as follows:-

    button1_click ()

    If(User.Identity.IsAuthenticated && User.Identity.Name != "sa");
    {

    //do whatever you want

    }

    else

    {
    Response.Redirect("loginpage.aspx");

    }

    Hope it helps.





    "Raghu Raman" wrote:
    > Hi,
    >
    > My query.
    >
    > I need to restrict invalid users of my **database**
    >
    > I did..
    >
    > i am creating an asp.net app in c#.net . some part of my websites
    > including the home page can be seen by any people . so that i checked
    > the anonymous users check box and removed all other authentications in
    > my directory settings of the virtual dir.
    >
    > my web.config file has
    >
    > for example , i want to restrict the user sa from accessing the
    > database. i did
    > ------------------------------------------------------------------------
    > -------------
    > <authentication mode="Forms">
    > <forms loginUrl="webform1.aspx" name=".aspauth"/>
    > </authentication>
    > <authorization>
    > <deny users="sa" />
    > </authorization>
    > * no impersonation
    > ------------------------------------------------------------------------
    > -------------
    > *If i run the app,
    >
    > the default startup page will be "webform1.aspx" .on that form ,i 've a
    > command but which opens the connection.It opens the connection
    > eventhough the user id=sa;
    >
    > What should i do, to restrict the user "sa"
    >
    > Thanks in advance ,
    > Raghu
    >
    >
    >
    >
    >
    >
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!
    >
    ranganh Guest

  4. #3

    Default RE: Help needed in Web.config



    Hi, thanks for that. but i did not get he result for that.it spits the
    error for the <location > tag.

    your suggestion
    --------------------------
    <location path="ProtectedPage.aspx">
    <system.web>
    <authorization>
    <deny users="?" />
    <deny users="sa" />
    </authorization>
    </system.web>
    </location>
    ------------------------------

    may be i am wrong in understanding of the web.config.
    --------------------------------
    let me clear on web.config
    --------------------------------
    1.the users tag in the web.config denotes the windows user account only
    ..
    2. it does not denotes the any database users.

    3. for 'forms' based authentication, since some of my pages of my web
    has to be seen , i should go for Anonymous authentication alone (or
    combined with Integrated windows Authentication) .

    4.Now i need to do nothing with the web.config. am i right???

    5.THEN HOW DO I RESTRICT THE DATABASE USERS.


    ***IS IT POSSIBLE TO RESTRICT DATABASE USERS IN WEB.CONFIG?**

    With regards
    Raghuraman


















    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Raghu Raman Guest

  5. #4

    Default RE: Help needed in Web.config

    Hi,

    You need to put the locationpath tag outside the system.web tag in your
    web.config.

    your web.config stars like this

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <system.web>

    // here you specify the authentication mode

    </system.web>

    //here you need to put the location path tag

    <location path="ProtectedPage.aspx">
    <system.web>
    <authorization>
    <deny users="?" />
    <deny users="sa" />
    </authorization>
    </system.web>
    </location>

    Notice that the above tag set themselves have a system.web tag. so they
    need to be outside the original <system.web>... </system.web> tags. in your
    web.config file.








    "Raghu Raman" wrote:
    >
    >
    > Hi, thanks for that. but i did not get he result for that.it spits the
    > error for the <location > tag.
    >
    > your suggestion
    > --------------------------
    > <location path="ProtectedPage.aspx">
    > <system.web>
    > <authorization>
    > <deny users="?" />
    > <deny users="sa" />
    > </authorization>
    > </system.web>
    > </location>
    > ------------------------------
    >
    > may be i am wrong in understanding of the web.config.
    > --------------------------------
    > let me clear on web.config
    > --------------------------------
    > 1.the users tag in the web.config denotes the windows user account only
    > ..
    > 2. it does not denotes the any database users.
    >
    > 3. for 'forms' based authentication, since some of my pages of my web
    > has to be seen , i should go for Anonymous authentication alone (or
    > combined with Integrated windows Authentication) .
    >
    > 4.Now i need to do nothing with the web.config. am i right???
    >
    > 5.THEN HOW DO I RESTRICT THE DATABASE USERS.
    >
    >
    > ***IS IT POSSIBLE TO RESTRICT DATABASE USERS IN WEB.CONFIG?**
    >
    > With regards
    > Raghuraman
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!
    >
    ranganh Guest

  6. #5

    Default RE: Help needed in Web.config

    Hi, thanks for that . i ll try it and get u back.

    but , u did'nt provide me the answer of the query.

    ** how can i restrict the db user in web.config?.please tolorate me.

    with regards
    Raghu


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Raghu Raman Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139