Access Denied

  • Hi !

    When trying to run the script I always get 'Access Denied'.

    DECLARE @DOSCOMMAND VARCHAR(4000)

    SET @DOSCOMMAND='dir \\server\shared_folder\'

    EXEC MASTER.DBO.XP_CMDSHELL @DOSCOMMAND

    I don't understand, because the shared folder as full acess to all users...

    What may be the problem ?

    Thanks in Advance,

    Pedro Martins

    V.N.Gaia

    Portugal


    Rechousa,
    V.N.Gaia
    Portugal

  • This command will run under the MS SQL Server service account. Is that service account set up to have network access (meaning is it a domain accout), or is it only a local administrator account. I'm assuming \\server\shared_folder is not on the local box.

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • Hi !

    We have two machines under different domains running win2000 server and sql server 2000.

    Running 'dir \\server\shared_folder\' from command shell it works just fine!

    Pedro Martins

    V.N.Gaia

    Portugal


    Rechousa,
    V.N.Gaia
    Portugal

  • DO u run this script with an user id who has sysadmin permissions on the server??

  • Hi !

    Yes. I run this script with an user id who has sysadmin permissions!

    Pedro Martins

    Rechousa,

    V.N.Gaia

    Portugal


    Rechousa,
    V.N.Gaia
    Portugal

  • Hi !

    Yes. I run this script with an user id who has sysadmin permissions!

    Pedro Martins


    Rechousa,
    V.N.Gaia
    Portugal

  • When you run this from the command shell are you logged on with the same account being used by MS SQL Server Service?

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • Consider, when you run it in a cmd prompt yourself, it is using your own security context to make the remote connection. When you run it thru SQL Server it is using the login account defined in services to control SQL Server. If you did not change then it is running as a system accoutn and will not be able to access remote machines. You must alter this for SQL by opening Enterprise Manager then right click the Server in the EM viewer and choose properties. On the security tab you find a section "Startup Service Account", set it to a user account specifically for SQL Server on the local machine or domain that has rights also to the other machine/domain to access the remote server. Then stop and start SQL Server and try again.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply