473,433 Members | 1,913 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,433 software developers and data experts.

xp_cmdshell 'dir "\\IPAddress\d$\" /b'; gives me access denied .

I want to access file from remote PC (LAN PC)but this line EXEC master..xp_cmdshell 'dir "\\192.168.0.2\d$\" /b';
gives "Access denied" message.
Jul 30 '10 #1
9 13303
ck9663
2,878 Expert 2GB
That means the account that the xp_cmdshell is using does not have the necessary rights on that folder. Not because you're the one logged in does not always mean your account will be used by the xp_cmdshell command.

More in here

Good Luck!!!

~~ CK
Jul 30 '10 #2
Jerry Winston
145 Expert 100+
because the account the sql server is using on the remote system does not have network privileges on the share. The best way to fix this is to create a windows login with permissions on this share, then use that windows login as a credential to assign to a SQL Login. When connected with the SQL Login the server will use the windows credential mapped to it when the server attempts to access the share. If you take a look at windows event viewer on the file share machine, you will see a list of failed attempts your server has made to the share. Once the Login running the xp_cmdshell command has a windows credential assigned to it you will see the windows login appear in the 'user' column of the event log.

FYI, whenever something goes wrong connecting to a file server, web server, or any server, the best place to start is with the log. You can often times find out who, what, how and what action failed.
Jul 30 '10 #3
Jerry Winston
145 Expert 100+
Create the credential
Expand|Select|Wrap|Line Numbers
  1. CREATE CREDENTIAL [xpCmdshellCredentialGuy]
  2. WITH IDENTITY = N'myWinDomain\myWinUser', SECRET = N'pwdpwd'
  3.  
Create the login:
Expand|Select|Wrap|Line Numbers
  1. CREATE LOGIN [cmd_User] 
  2. WITH PASSWORD=N'TopSeeCret', 
  3. DEFAULT_DATABASE=[MyDB], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF, CREDENTIAL = [xpCmdshellCredentialGuy]
  4.  
Create the user:
Expand|Select|Wrap|Line Numbers
  1. USE [MyDB]
  2. CREATE USER [cmd_User] FOR LOGIN [cmd_User] WITH DEFAULT_SCHEMA=[mySchema]
  3.  
Jul 30 '10 #4
@b0010100
My PC is not in domain so is it require?
Jul 31 '10 #5
NeoPa
32,556 Expert Mod 16PB
It should still be possible. I think b0010100 has a much better understanding of the SQL Server part of this puzzle than I, but remote connections to any Windows NT based PC are possible without a Windows domain being set up.

Why don't you describe the topology of your setup, including where your PC, the destination PC and the SQL Server PC fit in to it, and we can see what we can come up with.

Another approach, if you have the access, is to set up a specific share on the destination PC which has permissions set specifically for the account used by your SQL Server's SQL Server Agent account. D$ is what is known as an Admin share. Only accounts with administrator privileges can access them, even were other accounts to be assigned permissions. A share you set up yourself is far more flexible.

Welcome to Bytes!
Jul 31 '10 #6
@NeoPa
Hi...

Can you please write setups how to share folder with sql server agent account rights.because i tried a lots of time but still giving me a access denied.
Jul 31 '10 #7
@kinjalsoni
sorry tried*
Jul 31 '10 #8
Jerry Winston
145 Expert 100+
NeoPa is right about domains. It doesn't have to be setup.
When you share a windows folder it's never just plain "shared". It's always shared with a user, group, ect. Find out who your folder is shared with in the properties->sharing&security->permissions of the folder.

Make sure your server,through credentials, is connecting as someone that appears in the permissions for the share.

If the server is not connecting as a login or member of a group that the share trusts. you can create an user on the share machine for the SQL server to use as its credential. Or you can add the server to a group on the share machine that has rights to the folder.
Jul 31 '10 #9
NeoPa
32,556 Expert Mod 16PB
NeoPa: Why don't you describe the topology of your setup, including where your PC, the destination PC and the SQL Server PC fit in to it, and we can see what we can come up with.
kinjalsoni: Can you please write setups how to share folder with sql server agent account rights.because i tried a lots of time but still giving me a access denied.
Without even a basic understanding of how your network is set up this would be a waste of time. If I get a response from you to my earlier request, I may be in a postion to help further.
Aug 2 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: James Smith | last post by:
Hi, I'm having a problem with loading a page full of thumbnails. I'm useing this to load each thumbnail. header("Content-type: image/jpeg"); readfile ($dir."/thumbs/".$filename);
0
by: ASP.Confused | last post by:
The old message looked a little stale, so I am re-posting it here. Anybody have any ideas of what I could do?!? The previous responses to this question are below. If you want to look at the...
4
by: Martin | last post by:
Hi, I am getting an "Access Denied" error when attempting to browse asp.net pages. I have installed ASP.NET 1.1.4322 on a domain controller. The machine also has ASP.NET 1.0.3705 installed on...
2
by: LP | last post by:
Hi, I have a reporting application that exports data to different format and sends file to the browsers with the following code: string fileName = @"" + Request.QueryString; //fileName =...
2
by: Dave F. | last post by:
I just installed my ASP.NET app on a Win 2k server. I installed the files in a folder on D: and setup a virtual directory in IIS Default web. We had to install the Framework 1.1 and SP on this...
2
by: SKB | last post by:
Hi, I am absolutely new to this area. I am getting the following difficulty : Access denied for user 'ODBC'@'localhost' (using password: NO) when I try the mysql command from within the...
2
by: Chris Newby | last post by:
After googling this I got lots of information and tried a few different things. However pages for a particular site are still consistantly failing with "Access Denied to C:\ ... \Temporary Asp.Net...
5
by: hrpreet | last post by:
Hi All, I need the file chooser in the jsp, just for brosing and saving the file path in the database, so i have used the following code.I dont need to read the file content. I have to make it...
2
by: smjhunt | last post by:
I get this error intermittently in error reports submitted from users. Can't reproduce it myself. Most seem to be running XP so it's not a Vista issue. My C# code creates a temporary folder then...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.