accessing network shares while running remote WSH 
Author Message
 accessing network shares while running remote WSH

I'm running remote scripts (using the WSHRemote Object),
and I've run into a problem that I wasn't expecting. The
problem was that I was trying to write to a file on a
network drive and was getting a "permission denied" error.
To see what user my script was running under, I ran the
following code remotely:

var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.OpenTextFile("d:\\Test.txt",2, true);

var WshNetwork = WScript.CreateObject("WScript.Network");
f.WriteLine("Domain = " + WshNetwork.UserDomain);
f.WriteLine("Computer Name = " + WshNetwork.ComputerName);
f.WriteLine("User Name = " + WshNetwork.UserName);

The username (a domain user in the local admin group of
both servers I'm using) and computername were what I
expected, but the strange thing was that no domain was
returned. That explained my problem, so now I'm wondering
if there's a way around it. Is this behavior by design?

Thanks in advance,
Justin



Sun, 02 May 2004 08:13:52 GMT  
 accessing network shares while running remote WSH
The WshRemote instance is running under an impersonated account.  Under those circumstances it does not have access to remote machine resources (relative to the machine on which it is executing).  

This is exactly the same scenario as server side ASP script under anonymous or NTLM authentication.  In the ASP case there are workarounds, including Basic Authentication (or Kerberos on a Win2000 domain).

See the other (ugly) suggestions in the KB article below to see if any (other than Basic) might be appropriate in the WshRemote case though my recollection of this article is that the odds are slim at best...

Q207671 - HOWTO: Accessing Network Files from IIS Applications
http://support.microsoft.com/support/kb/articles/Q207/6/71.ASP

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:

> I'm running remote scripts (using the WSHRemote Object),
> and I've run into a problem that I wasn't expecting. The
> problem was that I was trying to write to a file on a
> network drive and was getting a "permission denied" error.
> To see what user my script was running under, I ran the
> following code remotely:

> var fso = new ActiveXObject("Scripting.FileSystemObject");
> var f = fso.OpenTextFile("d:\\Test.txt",2, true);

> var WshNetwork = WScript.CreateObject("WScript.Network");
> f.WriteLine("Domain = " + WshNetwork.UserDomain);
> f.WriteLine("Computer Name = " + WshNetwork.ComputerName);
> f.WriteLine("User Name = " + WshNetwork.UserName);

> The username (a domain user in the local admin group of
> both servers I'm using) and computername were what I
> expected, but the strange thing was that no domain was
> returned. That explained my problem, so now I'm wondering
> if there's a way around it. Is this behavior by design?

> Thanks in advance,
> Justin



Mon, 03 May 2004 00:48:43 GMT  
 accessing network shares while running remote WSH

You can also use sfimpersonator for this. I use it in several ASP pages and it works great. Sfimpersonator.dll (including the source) can be found on my site in the tools section.

Clarence

Win32Scripting...
Not that one by Duke Publishing. The ORIGINAL!
Over 500 scripts and over 50 COM objects to download and use FREE of charge.
Also check out the public online forum and chat rooms for community based
technical support.
.
http://cwashington.netreach.net


The WshRemote instance is running under an impersonated account.  Under those circumstances it does not have access to remote machine resources (relative to the machine on which it is executing).  

This is exactly the same scenario as server side ASP script under anonymous or NTLM authentication.  In the ASP case there are workarounds, including Basic Authentication (or Kerberos on a Win2000 domain).

See the other (ugly) suggestions in the KB article below to see if any (other than Basic) might be appropriate in the WshRemote case though my recollection of this article is that the odds are slim at best...

Q207671 - HOWTO: Accessing Network Files from IIS Applications
http://support.microsoft.com/support/kb/articles/Q207/6/71.ASP

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:

> I'm running remote scripts (using the WSHRemote Object),
> and I've run into a problem that I wasn't expecting. The
> problem was that I was trying to write to a file on a
> network drive and was getting a "permission denied" error.
> To see what user my script was running under, I ran the
> following code remotely:

> var fso = new ActiveXObject("Scripting.FileSystemObject");
> var f = fso.OpenTextFile("d:\\Test.txt",2, true);

> var WshNetwork = WScript.CreateObject("WScript.Network");
> f.WriteLine("Domain = " + WshNetwork.UserDomain);
> f.WriteLine("Computer Name = " + WshNetwork.ComputerName);
> f.WriteLine("User Name = " + WshNetwork.UserName);

> The username (a domain user in the local admin group of
> both servers I'm using) and computername were what I
> expected, but the strange thing was that no domain was
> returned. That explained my problem, so now I'm wondering
> if there's a way around it. Is this behavior by design?

> Thanks in advance,
> Justin



Mon, 03 May 2004 00:56:05 GMT  
 accessing network shares while running remote WSH
Thanks Clarence. One question...I can't get sfimpersonator
to work. I registered the dll, but when I run the test
script that came with the download, I get this error:

"A required privilege is not held by the client."

The error references the line that executes the Impersonate
() method. Any ideas? I emailed the guy that wrote the
component but haven't heard back from him. Thought you may
have seen this before.  Any ideas?

Thanks,
Justin

Quote:
>-----Original Message-----
>You can also use sfimpersonator for this. I use it in

several ASP pages and it works great. Sfimpersonator.dll
(including the source) can be found on my site in the
tools section.
Quote:

>Clarence

>Win32Scripting...
>Not that one by Duke Publishing. The ORIGINAL!
>Over 500 scripts and over 50 COM objects to download and
use FREE of charge.
>Also check out the public online forum and chat rooms for
community based
>technical support.
>..
>http://cwashington.netreach.net




Quote:
>The WshRemote instance is running under an impersonated

account.  Under those circumstances it does not have
access to remote machine resources (relative to the
machine on which it is executing).  
Quote:

>This is exactly the same scenario as server side ASP

script under anonymous or NTLM authentication.  In the ASP
case there are workarounds, including Basic Authentication
(or Kerberos on a Win2000 domain).
Quote:

>See the other (ugly) suggestions in the KB article below

to see if any (other than Basic) might be appropriate in
the WshRemote case though my recollection of this article
is that the odds are slim at best...
Quote:

>Q207671 - HOWTO: Accessing Network Files from IIS
Applications
>http://support.microsoft.com/support/kb/articles/Q207/6/71
.ASP

>--
>Michael Harris
>Microsoft.MVP.Scripting
>--




Quote:
>> I'm running remote scripts (using the WSHRemote
Object),
>> and I've run into a problem that I wasn't expecting.
The
>> problem was that I was trying to write to a file on a
>> network drive and was getting a "permission denied"
error.
>> To see what user my script was running under, I ran the
>> following code remotely:

>> var fso = new ActiveXObject

("Scripting.FileSystemObject");
Quote:
>> var f = fso.OpenTextFile("d:\\Test.txt",2, true);

>> var WshNetwork = WScript.CreateObject

("WScript.Network");
Quote:
>> f.WriteLine("Domain = " + WshNetwork.UserDomain);
>> f.WriteLine("Computer Name = " +

WshNetwork.ComputerName);
Quote:
>> f.WriteLine("User Name = " + WshNetwork.UserName);

>> The username (a domain user in the local admin group of
>> both servers I'm using) and computername were what I
>> expected, but the strange thing was that no domain was
>> returned. That explained my problem, so now I'm
wondering
>> if there's a way around it. Is this behavior by design?

>> Thanks in advance,
>> Justin



Mon, 03 May 2004 06:53:12 GMT  
 accessing network shares while running remote WSH

The user attempting to do the impersonation needs to have "act as part of the operating system" rights.

Clarence

Win32Scripting...
Not that one by Duke Publishing. The ORIGINAL!
Over 500 scripts and over 50 COM objects to download and use FREE of charge.
Also check out the public online forum and chat rooms for community based
technical support.
.

http://cwashington.netreach.net

Quote:

> Thanks Clarence. One question...I can't get sfimpersonator
> to work. I registered the dll, but when I run the test
> script that came with the download, I get this error:

> "A required privilege is not held by the client."

> The error references the line that executes the Impersonate
> () method. Any ideas? I emailed the guy that wrote the
> component but haven't heard back from him. Thought you may
> have seen this before.  Any ideas?

> Thanks,
> Justin

> >-----Original Message-----
> >You can also use sfimpersonator for this. I use it in
> several ASP pages and it works great. Sfimpersonator.dll
> (including the source) can be found on my site in the
> tools section.

> >Clarence

> >Win32Scripting...
> >Not that one by Duke Publishing. The ORIGINAL!
> >Over 500 scripts and over 50 COM objects to download and
> use FREE of charge.
> >Also check out the public online forum and chat rooms for
> community based
> >technical support.
> >..
> >http://cwashington.netreach.net



> >The WshRemote instance is running under an impersonated
> account.  Under those circumstances it does not have
> access to remote machine resources (relative to the
> machine on which it is executing).  

> >This is exactly the same scenario as server side ASP
> script under anonymous or NTLM authentication.  In the ASP
> case there are workarounds, including Basic Authentication
> (or Kerberos on a Win2000 domain).

> >See the other (ugly) suggestions in the KB article below
> to see if any (other than Basic) might be appropriate in
> the WshRemote case though my recollection of this article
> is that the odds are slim at best...

> >Q207671 - HOWTO: Accessing Network Files from IIS
> Applications
> >http://support.microsoft.com/support/kb/articles/Q207/6/71
> .ASP

> >--
> >Michael Harris
> >Microsoft.MVP.Scripting
> >--



> >> I'm running remote scripts (using the WSHRemote
> Object),
> >> and I've run into a problem that I wasn't expecting.
> The
> >> problem was that I was trying to write to a file on a
> >> network drive and was getting a "permission denied"
> error.
> >> To see what user my script was running under, I ran the
> >> following code remotely:

> >> var fso = new ActiveXObject
> ("Scripting.FileSystemObject");
> >> var f = fso.OpenTextFile("d:\\Test.txt",2, true);

> >> var WshNetwork = WScript.CreateObject
> ("WScript.Network");
> >> f.WriteLine("Domain = " + WshNetwork.UserDomain);
> >> f.WriteLine("Computer Name = " +
> WshNetwork.ComputerName);
> >> f.WriteLine("User Name = " + WshNetwork.UserName);

> >> The username (a domain user in the local admin group of
> >> both servers I'm using) and computername were what I
> >> expected, but the strange thing was that no domain was
> >> returned. That explained my problem, so now I'm
> wondering
> >> if there's a way around it. Is this behavior by design?

> >> Thanks in advance,
> >> Justin



Mon, 03 May 2004 07:15:16 GMT  
 accessing network shares while running remote WSH
Thanks. That fixed it!

Justin

Quote:
>-----Original Message-----
>The user attempting to do the impersonation needs to

have "act as part of the operating system" rights.
Quote:

>Clarence

>Win32Scripting...
>Not that one by Duke Publishing. The ORIGINAL!
>Over 500 scripts and over 50 COM objects to download and
use FREE of charge.
>Also check out the public online forum and chat rooms for
community based
>technical support.
>..

>http://cwashington.netreach.net




- Show quoted text -

Quote:
>> Thanks Clarence. One question...I can't get
sfimpersonator
>> to work. I registered the dll, but when I run the test
>> script that came with the download, I get this error:

>> "A required privilege is not held by the client."

>> The error references the line that executes the
Impersonate
>> () method. Any ideas? I emailed the guy that wrote the
>> component but haven't heard back from him. Thought you
may
>> have seen this before.  Any ideas?

>> Thanks,
>> Justin

>> >-----Original Message-----
>> >You can also use sfimpersonator for this. I use it in
>> several ASP pages and it works great.
Sfimpersonator.dll
>> (including the source) can be found on my site in the
>> tools section.

>> >Clarence

>> >Win32Scripting...
>> >Not that one by Duke Publishing. The ORIGINAL!
>> >Over 500 scripts and over 50 COM objects to download
and
>> use FREE of charge.
>> >Also check out the public online forum and chat rooms
for
>> community based
>> >technical support.
>> >..
>> >http://cwashington.netreach.net


message

>> >The WshRemote instance is running under an
impersonated
>> account.  Under those circumstances it does not have
>> access to remote machine resources (relative to the
>> machine on which it is executing).  

>> >This is exactly the same scenario as server side ASP
>> script under anonymous or NTLM authentication.  In the
ASP
>> case there are workarounds, including Basic
Authentication
>> (or Kerberos on a Win2000 domain).

>> >See the other (ugly) suggestions in the KB article
below
>> to see if any (other than Basic) might be appropriate
in
>> the WshRemote case though my recollection of this
article
>> is that the odds are slim at best...

>> >Q207671 - HOWTO: Accessing Network Files from IIS
>> Applications

>http://support.microsoft.com/support/kb/articles/Q207/6/71
>> .ASP

>> >--
>> >Michael Harris
>> >Microsoft.MVP.Scripting
>> >--





- Show quoted text -

Quote:
>> >> I'm running remote scripts (using the WSHRemote
>> Object),
>> >> and I've run into a problem that I wasn't expecting.
>> The
>> >> problem was that I was trying to write to a file on
a
>> >> network drive and was getting a "permission denied"
>> error.
>> >> To see what user my script was running under, I ran
the
>> >> following code remotely:

>> >> var fso = new ActiveXObject
>> ("Scripting.FileSystemObject");
>> >> var f = fso.OpenTextFile("d:\\Test.txt",2, true);

>> >> var WshNetwork = WScript.CreateObject
>> ("WScript.Network");
>> >> f.WriteLine("Domain = " + WshNetwork.UserDomain);
>> >> f.WriteLine("Computer Name = " +
>> WshNetwork.ComputerName);
>> >> f.WriteLine("User Name = " + WshNetwork.UserName);

>> >> The username (a domain user in the local admin group
of
>> >> both servers I'm using) and computername were what I
>> >> expected, but the strange thing was that no domain
was
>> >> returned. That explained my problem, so now I'm
>> wondering
>> >> if there's a way around it. Is this behavior by
design?

>> >> Thanks in advance,
>> >> Justin



Mon, 03 May 2004 08:09:52 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. access to network share in remote script

2. remote Authentication for running a remote wsh script

3. FolderExists reports true on a network share when I have no access

4. Network / Shared Drive Access

5. Remotely initiated script cannot access network shares?

6. Remote access network

7. WMI - Launching an Application With Network Access on a Remote Machine

8. Connecting to network shares when network is detected only - help please

9. Gripes about WSH...also a specific problem with accessing shares

10. Again: No username while running WSH.Network in W95 logon

11. Accessing the Network Neighborhood in WSH VBScript

12. running WSH cript on remote computer

 

 
Powered by phpBB® Forum Software