none
Msg 15151, Level 16, State 1, Line 5 (Cannot find the user)

    Domanda

  • I'm getting a specific error when i try to run a .sql script for a Custom TableProfile from the Asp.net site,when i Parse the .sql file Commands execute perfectly. But when i actually "Execute" the   .sql script i get the following errors::

     

    Msg 15151, Level 16, State 1, Line 5

    Cannot find the user 'WYATT-PC\Wyatt\ASPNET', because it does not exist or you do not have permission.

     

     

     

    How can i fix this??

     

     

     

    Thxs in Advance Rattlerr

    giovedì 26 aprile 2007 20:23

Tutte le risposte

  • I have a .sql script that will run just fine when i remove the following script lines::

     

    grant EXECUTE on dbo.aspnet_Applications_CreateApplication to [YOURMACHINENAME\ASPNET]

    grant EXECUTE on dbo.aspnet_Users_CreateUser to [YOURMACHINENAME\ASPNET]

    grant SELECT on dbo.aspnet_Users to [YOURMACHINENAME\ASPNET]

    grant UPDATE on dbo.aspnet_Users(LastActivityDate) to [YOURMACHINENAME\ASPNET]

    go

     

    I'm using Sql Server 2005 Advanced logging in threw "Windows Authentication", in the Security Folder ----> Login Folder Wyatt-PC

    \Wyatt has all the Server Rolls checked ( bulkadmin, dbcreator, diskadmin, processadmin, public, securityadmin, serveradmin, setupadmin & sysadmin). The Login name is: Wyatt-PC\Wyatt..

     

    I would assume [YOURMACHINENAME] would be the name of my computer which is the same as the Login,so i'm abit confused..Thxs for the help in Advance Rattlerr

     

    But i can't figure out why the above script lines produce this error::

     

    Msg 15151, Level 16, State 1, Line 5

    Cannot find the user 'Wyatt-PC\ASPNET', because it does not exist or you do not have permission.

    venerdì 27 aprile 2007 02:00
  • I don´t know if I get you right, is the WebServer on the same Machine as the SQL Server ? If not the SQL Server does not know about your local accounts.


    Jens K. Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---
    venerdì 27 aprile 2007 10:37
  • yeah, the Webserver is on the same machine as the Sql Server itself. I guess i should run a Re Install of the Sql Server to see if it fixes the issue?

     

    But any suggestions on this problem is greatly appreciated..Thxs in advance Rattlerr

     

    PS: i even set the Permissions up threw the GUI but the same error continues::

     

    Right Click The Table or Stored Procedure go too Properties, than Permissions.. Their is where i even selected the Execute for a User Account but still no go..

     

    Here is the sampleSchema Script that i'm trying to use, I have setup the Permissions mentioned above manully the "Execute,Update, Select,Insert & Delete you see in the Script..

     

     

    Code Snippet

    --Set this to the name of your database

    --

    use TableProfileProviders

    go

    --

    --grants on ASP.NET stored procedures and tables used by the custom providers

    --

    grant EXECUTE on dbo.aspnet_Applications_CreateApplication to [YOURMACHINENAME\ASPNET]

    grant EXECUTE on dbo.aspnet_Users_CreateUser to [YOURMACHINENAME\ASPNET]

    grant SELECT on dbo.aspnet_Users to [YOURMACHINENAME\ASPNET]

    grant UPDATE on dbo.aspnet_Users(LastActivityDate) to [YOURMACHINENAME\ASPNET]

    go

    --drop table dbo.ProfileTable_1

    --go

    create table dbo.ProfileTable_1 (

    UserId uniqueidentifier not null Primary Key,

    FirstName nvarchar(50) null,

    LastName nvarchar(50) null,

    Age int null,

    LastUpdatedDate datetime not null)

    go

    grant SELECT,INSERT,UPDATE,DELETE on dbo.ProfileTable_1 to [YOURMACHINENAME\ASPNET]

    go

    --

    --Get stored procedure

    --

    --drop procedure getCustomProfileData

    create procedure getCustomProfileData

    @ApplicationName nvarchar(256),

    @UserName nvarchar(256),

    @FirstName nvarchar(50) OUTPUT,

    @LastName nvarchar(50) OUTPUT,

    @Age int OUTPUT

    as

    declare @ApplicationId uniqueidentifier

    set @ApplicationId = NULL

    --Get the appid

    exec dbo.aspnet_Applications_CreateApplication @ApplicationName, @ApplicationId OUTPUT

    --Return data for the requested user in the application

    select @FirstName = FirstName,

    @LastName = LastName,

    @Age = Age

    from dbo.ProfileTable_1 pt,

    dbo.vw_aspnet_Users u

    where u.ApplicationId = @ApplicationId

    and u.UserName = @UserName

    and u.UserId = pt.UserId

    go

    grant EXECUTE on dbo.getCustomProfileData to [YOURMACHINENAME\ASPNET]

    go

    --

    --Set stored procedure

    --

    --drop procedure setCustomProfileData

    create procedure setCustomProfileData

    @ApplicationName nvarchar(256),

    @UserName nvarchar(256),

    @IsUserAnonymous bit,

    @FirstName nvarchar(50),

    @LastName nvarchar(50),

    @Age int

    as

    declare @ApplicationId uniqueidentifier

    set @ApplicationId = NULL

    declare @CurrentUtcDate datetime

    set @CurrentUtcDate = getutcdate()

    --Get the appid

    exec dbo.aspnet_Applications_CreateApplication @ApplicationName, @ApplicationId OUTPUT

    --Create user if needed

    declare @UserId uniqueidentifier

    select @UserId = UserId

    from dbo.vw_aspnet_Users

    where ApplicationId = @ApplicationId

    and LoweredUserName = LOWER(@UserName)

    if(@UserId IS NULL)

    exec dbo.aspnet_Users_CreateUser @ApplicationId, @UserName, @IsUserAnonymous, @CurrentUtcDate, @UserId OUTPUT

    --Either insert a new row of data, or update a pre-existing row

    if exists (select 1 from dbo.ProfileTable_1 where UserId = @UserId)

    BEGIN

    update dbo.ProfileTable_1

    set FirstName = @FirstName,

    LastName = @LastName,

    Age = @Age,

    LastUpdatedDate = @CurrentUtcDate

    where UserId = @UserId

    END

    else

    BEGIN

    insert dbo.ProfileTable_1 (UserId, FirstName, LastName, Age, LastUpdatedDate)

    values (@UserId, @FirstName, @LastName, @Age, @CurrentUtcDate)

    END

    go

    grant EXECUTE on dbo.setCustomProfileData to [YOURMACHINENAME\ASPNET]

    go

     

    venerdì 27 aprile 2007 20:12
  • And yes the ISS Server is installed i checked to see if it was running and it is..When i went to do a Re Install of Sql Server 2005 Advanced a Warning showed up for the IIS Server. Now i have read people running Vista are having this issue, i looked in my Task manager under Services the following is their and running:

     

    IISADMIN = IIS Admin Service::

     

    Description:

     

    Enables this server to administer metabase FTP services etc etc

     

    And the IIS server is in the Administrative Panel

    venerdì 27 aprile 2007 20:32
  • Doesn't any have an idea of whats going on here?? why the "Grant" statements in the script i posted cause's this error?? I mean this is a Sql Server Forum someone has to know something about this
    domenica 29 aprile 2007 19:48
  • This is how I fixed it:

    When I execute the grant statement I made sure I was in the database

    Use [MyDBName]
    grant select on [tablename] to [username]

    go

    domenica 13 settembre 2009 14:10