SQL Server/IIS login problems

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default SQL Server/IIS login problems

    I have written a simple web app that connects to a local instance of
    SQL Server to run queries. The virtual directory in IIS is "myapp",
    and there is a default.asp file in there. In myapp properties/
    directory security/ authentication, I have disabled "basic
    authentication" and "integrated windows authentication" and enabled
    anonymous access. I have created a restricted user called "MYAPPUSER"
    in Windows and this is the user that is granted anonymous access. I
    have also executed the following query in my sql server to give access
    to the user:

    CREATE DATABASE MYAPPDB
    EXEC sp_grantlogin 'COMPUTERNAME\MYAPPUSER'
    USE MYAPPDB
    EXEC sp_grantdbaccess 'COMPUTERNAME\MYAPPUSER'
    EXEC sp_addrolemember 'db_owner', 'COMPUTERNAME\MYAPPUSER'

    If I try to access my sql server with this connection string:

    "Provider=sqloledb;Integrated Security='SSPI';Initial Catalog=myapp;"

    I get:

    Error Type: Microsoft OLE DB Provider for SQL Server (0x80040E4D)
    Login failed for user 'COMPUTERNAME\MYAPPUSER'.
    /myapp/default.asp, line 34

    If I change this user to an Administrator, I can access the sql server
    fine. However, I don't want to give the user Administrator priveliges.
    Is there some way I can restrict the users access while still allowing
    to it to log in to sql server?

    Furthermore, if I try to access this page remotely on a Windows XP
    machine, I get the error:

    HTTP 401.2 - Unauthorized: Logon failed due to server configuration
    Internet Information Services

    I don't think this even has anything to do with the fact that the asp
    accesses the sql server, rather it's just plain not able to access the
    files or something.

    Perhaps I'm going about this all wrong. Given the specifications I've
    outlined, could anyone perhaps let me know what would be the best way
    to lay out my access control for this? I need to be able to access the
    sql server, but I don't want to have to enter a user name and password
    every time I go to the page like with Basic Authentication. And I'm
    potentially going to need to access the page through a firewall or via
    a proxy server, so I can't use Integrated Windows Authentication.
    That's why I chose Anonymous Access...

    I'm stuck! Help!

    Dylan
    Dylan Guest

  2. Similar Questions and Discussions

    1. Login and New User Problems
      I'm using php for my website and I add in the insert record and then check new user to a page. Then when I go check the page in my web browser it...
    2. Login problems.....
      Im running PHP / MySQL and are building up two different websites at the moment. I have no problem addint the dynamic data, recordsets, login...
    3. User Login Problems
      Hello and thanks in advance. I want to preface by saying the network I am on prohibits me from using the application panel to define my database...
    4. PHP Local Login Problems
      Trying to log in to PHP local server on Mac OS X. I keep getting an error message about the testing server. What exactly do I put into the testing...
    5. PLEASE? Any way to get the user's nt login from the pc -- not the server login?
      Hi, string sUser = Request.ServerVariables ; Natty Gur, CTO Dao2Com Ltd. 28th Baruch Hirsch st. Bnei-Brak Israel , 51114 Phone Numbers:...
  3. #2

    Default Re: SQL Server/IIS login problems

    Hi there:

    a) Is anonymous access enabled in the IIS MMC Snapin for the website in
    question?

    b) Is the anonymous internet user account (in the IIS MMC Snapin) set to:
    'COMPUTERNAME\MYAPPUSER' (and optionally, have you either entered the
    appropriate password manually -or- checked the box that says "Allow IIS to
    control password"?)

    c) Does: 'COMPUTERNAME\MYAPPUSER' have NTFS Read/Execute permissions for the
    ..asp files in question that you want to run?

    If all the above are correct, then:
    a) you should be able to access the site "anonymously".
    b) IIS will use the configured anonymous account ('COMPUTERNAME\MYAPPUSER')
    to read the .asp pages off the disk
    c) the ASP pages attempt to connect to the database under the current NT
    account context, which is 'COMPUTERNAME\MYAPPUSER', and you have granted
    that account permission to login to the database.


    Cheers
    Ken




    "Dylan" <heavier@hotmail.com> wrote in message
    news:55b5617b.0307081248.5e27d6e9@posting.google.c om...
    : I have written a simple web app that connects to a local instance of
    : SQL Server to run queries. The virtual directory in IIS is "myapp",
    : and there is a default.asp file in there. In myapp properties/
    : directory security/ authentication, I have disabled "basic
    : authentication" and "integrated windows authentication" and enabled
    : anonymous access. I have created a restricted user called "MYAPPUSER"
    : in Windows and this is the user that is granted anonymous access. I
    : have also executed the following query in my sql server to give access
    : to the user:
    :
    : CREATE DATABASE MYAPPDB
    : EXEC sp_grantlogin 'COMPUTERNAME\MYAPPUSER'
    : USE MYAPPDB
    : EXEC sp_grantdbaccess 'COMPUTERNAME\MYAPPUSER'
    : EXEC sp_addrolemember 'db_owner', 'COMPUTERNAME\MYAPPUSER'
    :
    : If I try to access my sql server with this connection string:
    :
    : "Provider=sqloledb;Integrated Security='SSPI';Initial Catalog=myapp;"
    :
    : I get:
    :
    : Error Type: Microsoft OLE DB Provider for SQL Server (0x80040E4D)
    : Login failed for user 'COMPUTERNAME\MYAPPUSER'.
    : /myapp/default.asp, line 34
    :
    : If I change this user to an Administrator, I can access the sql server
    : fine. However, I don't want to give the user Administrator priveliges.
    : Is there some way I can restrict the users access while still allowing
    : to it to log in to sql server?
    :
    : Furthermore, if I try to access this page remotely on a Windows XP
    : machine, I get the error:
    :
    : HTTP 401.2 - Unauthorized: Logon failed due to server configuration
    : Internet Information Services
    :
    : I don't think this even has anything to do with the fact that the asp
    : accesses the sql server, rather it's just plain not able to access the
    : files or something.
    :
    : Perhaps I'm going about this all wrong. Given the specifications I've
    : outlined, could anyone perhaps let me know what would be the best way
    : to lay out my access control for this? I need to be able to access the
    : sql server, but I don't want to have to enter a user name and password
    : every time I go to the page like with Basic Authentication. And I'm
    : potentially going to need to access the page through a firewall or via
    : a proxy server, so I can't use Integrated Windows Authentication.
    : That's why I chose Anonymous Access...
    :
    : I'm stuck! Help!
    :
    : Dylan


    Ken Schaefer Guest

  4. #3

    Default Re: SQL Server/IIS login problems

    > a) Is anonymous access enabled in the IIS MMC Snapin for > the website
    in
    > question?
    Yes.
    > b) Is the anonymous internet user account (in the IIS MMC > Snapin)
    set to:
    > 'COMPUTERNAME\MYAPPUSER' (and optionally, have you either > entered
    the
    > appropriate password manually -or- checked the box that
    > says "Allow IIS to
    > control password"?)
    Yes, I control the password. There is none (i.e: "").
    > c) Does: 'COMPUTERNAME\MYAPPUSER' have NTFS Read/Execute > permissions
    for the
    > ..asp files in question that you want to run?
    In W2k, yes. I set the permissions. In XP, I did not set them
    explicitly, but even when I set the user to an admin, I get 401.2.
    > If all the above are correct, then:
    > a) you should be able to access the site "anonymously".
    > b) IIS will use the configured anonymous account
    > ('COMPUTERNAME\MYAPPUSER')
    > to read the .asp pages off the disk
    > c) the ASP pages attempt to connect to the database under > the
    current NT
    > account context, which is 'COMPUTERNAME\MYAPPUSER', and
    > you have granted
    > that account permission to login to the database.
    Agreed. I would think that it should work. But it doesn't. Like I said,
    in W2k, it works if I set the user to an admin, and in XP, it doesn't
    work no matter what.

    I'm pretty sure the XP problem is a windows permissions problem, because
    I just plain can't access the page. But in W2k, it's a SQL problem. What
    are the differences in security b/w W2k and XP? I was under the
    impression that they're basically the same (i.e: NT5)...

    Thanks for the response,

    Dylan


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

  5. #4

    Default Re: SQL Server/IIS login problems

    Hi,

    The pages are running on the same machine right? (ie in the first case you
    are accessing the website by using a browser on the server, and in the
    second case you are accessing the same webserver, but remotely from a
    WindowsXP machine)

    Or did I intepret your original post incorrectly?

    Cheers
    Ken

    "Dylan Smith" <heavier@hotmail.com> wrote in message
    news:%235Am7xhRDHA.2768@tk2msftngp13.phx.gbl...
    : > a) Is anonymous access enabled in the IIS MMC Snapin for > the website
    : in
    : > question?
    :
    : Yes.
    :
    : > b) Is the anonymous internet user account (in the IIS MMC > Snapin)
    : set to:
    : > 'COMPUTERNAME\MYAPPUSER' (and optionally, have you either > entered
    : the
    : > appropriate password manually -or- checked the box that
    : > says "Allow IIS to
    : > control password"?)
    :
    : Yes, I control the password. There is none (i.e: "").
    :
    : > c) Does: 'COMPUTERNAME\MYAPPUSER' have NTFS Read/Execute > permissions
    : for the
    : > ..asp files in question that you want to run?
    :
    : In W2k, yes. I set the permissions. In XP, I did not set them
    : explicitly, but even when I set the user to an admin, I get 401.2.
    :
    : > If all the above are correct, then:
    : > a) you should be able to access the site "anonymously".
    : > b) IIS will use the configured anonymous account
    : > ('COMPUTERNAME\MYAPPUSER')
    : > to read the .asp pages off the disk
    : > c) the ASP pages attempt to connect to the database under > the
    : current NT
    : > account context, which is 'COMPUTERNAME\MYAPPUSER', and
    : > you have granted
    : > that account permission to login to the database.
    :
    : Agreed. I would think that it should work. But it doesn't. Like I said,
    : in W2k, it works if I set the user to an admin, and in XP, it doesn't
    : work no matter what.
    :
    : I'm pretty sure the XP problem is a windows permissions problem, because
    : I just plain can't access the page. But in W2k, it's a SQL problem. What
    : are the differences in security b/w W2k and XP? I was under the
    : impression that they're basically the same (i.e: NT5)...
    :
    : Thanks for the response,
    :
    : Dylan
    :
    :
    : *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    : Don't just participate in USENET...get rewarded for it!


    Ken Schaefer 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