xp_cmdshell copy to nfs share fails

  • xp_cmdshell 'copy d:\1.txt \\4690server\folder'

    When I issue the above command using Query Analyzer or a Stored Procedure I get the message:

    Logon failure: unknown user name or bad password.

            0 file(s) copied.

    NULL

    If I issue it through a job, or through a command prompt, it succeeds. I need to run it through stored procedure, but it fails. Any ideas?

    Thanks...Nali

  • Hello Nali,

    Are you using Windows NT user or SQL User login?

    Does the user login has required access to the shared folder?

    Please go through the "Remarks" section of xp_cmdshell in Books Online.

    Thanks and have a nice day!!!


    Lucky

  • I tried both. NT had admin rights, and also the SA SQL user login.

    The shared folder is open to everything, and is an NFS share on a 4690 box.

    Read the "Remarks" section, and tried logging on and various combinations for the agent service account.

    I still get the same error.....

  • Ok do the following steps:

    1. Check with which account both SQL Server and Agent have been started.

    2. If Windows domain account, then check whether the shared folder has the full control on it.

    This will solve.

    Thanks and have a nice day!!!


    Lucky

  • Check the permissions on the shared folder for the account on which sql server is running..

    When xp_cmdshell is invoked by a user who is a member of the sysadmin fixed server role, xp_cmdshell will be executed under the security context in which the SQL Server service is running.

    Since you said it runs fine when executed as a job then it is executed under the context of SQL Server Agent account.

    Are the Agent and SQL Server running under different accounts?

     

     

    -Krishnan

  • Thanks for all of your help.

    The solution was to change the SQL service account, not the agent account, to run under the local service account. Previously it was running under a local admin and domain admin account. Seems counter intuitive to me.

    Thanks again!

  • Hi Nali,

    1.        Hope you have got the problem of authentication at first point. Check if it is mixed mode authentication.

    2.       Secondly you should check the Disk Administrator role under Server Role in properties of a user who is executing the procedure. Be sure that the destination folder is the root path from where you are putting cmd shell command. The folder where you are copying is the default path on the cmd prompt. where the stored proc is getting executed.

    Thanks.

    Suraj Pardeshi

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

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