PC Review


Reply
Thread Tools Rate Thread

access network share via service using a non LocalSystem Account

 
 
Florian Rosenauer
Guest
Posts: n/a
 
      5th Jun 2008
Hi,

I cannot access network shares (mapped to drive letters) from a
service.
The Service (srvany with Cruise Control) is configured to run as a
local user account, not LocalSystem.

When I log in as the same local user and execute the batch file
everything works.
When I run it using the MS Taskplanner Service as a task configured to
run as the local user account everything works.

I do not understand why executing a process using the context of a
local user behaves different based on how it is called.
The only difference is that mstask.exe creates a visible windows
whereas srvany does not?

Does anyone habe an idea?

Thanks
Florian
 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      5th Jun 2008

"Florian Rosenauer" <(E-Mail Removed)> wrote in message
news:4dbae2d8-d4e5-44ba-96ae-(E-Mail Removed)...
> Hi,
>
> I cannot access network shares (mapped to drive letters) from a
> service.
> The Service (srvany with Cruise Control) is configured to run as a
> local user account, not LocalSystem.
>
> When I log in as the same local user and execute the batch file
> everything works.
> When I run it using the MS Taskplanner Service as a task configured to
> run as the local user account everything works.
>
> I do not understand why executing a process using the context of a
> local user behaves different based on how it is called.
> The only difference is that mstask.exe creates a visible windows
> whereas srvany does not?
>
> Does anyone habe an idea?
>
> Thanks
> Florian


You write:
> When I log in as the same local user and execute the batch file
> everything works.
> When I run it using the MS Taskplanner Service as a task configured to
> run as the local user account everything works.

Isn't there a "not" missing somewhere in the second statement?

If so then I suggest you post the batch file you use.


 
Reply With Quote
 
Florian Rosenauer
Guest
Posts: n/a
 
      10th Jun 2008
On 5 Jun., 16:57, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> You write:
> When I log in as the same local user and execute the batch file
> > everything works.
> > When I run it using the MS Taskplanner Service as a task configured to
> > run as the local user account everything works.

>
> Isn't there a "not" missing somewhere in the second statement?
>
> If so then I suggest you post the batch file you use


My Batch File (anonymonized)
net use
net use F: /delete
net use F: \\server\share password /user:domain\domainuser
dir F:

there is no "NOT" missing.
when running as local logged in user it works
when running via Task-Planner Service as local user it works
when running via srvany (from cruise control) as local user it does
not work

the taskplanner service runs as LocalSystem und starts my batch file
using the security context of the local user
the srvany runs as local user and therefore any sub-process runs as
local user (I already checked that using sysinternals process
explorer)

the output of "net use" is interesting: as local user and via task-
planner it shows the permanent connected drives, running it via
crusiecontrol it says there are no entries in the list
but the "net use F: \\server\share password /user:domain\domainuser"
tells me that the local drive letter is already used (error 85)

it's confusing
 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      10th Jun 2008

"Florian Rosenauer" <(E-Mail Removed)> wrote in message
news:d663a4ce-0605-485c-a374-(E-Mail Removed)...
> On 5 Jun., 16:57, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
>> You write:
>> When I log in as the same local user and execute the batch file
>> > everything works.
>> > When I run it using the MS Taskplanner Service as a task configured to
>> > run as the local user account everything works.

>>
>> Isn't there a "not" missing somewhere in the second statement?
>>
>> If so then I suggest you post the batch file you use

>
> My Batch File (anonymonized)
> net use
> net use F: /delete
> net use F: \\server\share password /user:domain\domainuser
> dir F:
>
> there is no "NOT" missing.
> when running as local logged in user it works
> when running via Task-Planner Service as local user it works
> when running via srvany (from cruise control) as local user it does
> not work
>
> the taskplanner service runs as LocalSystem und starts my batch file
> using the security context of the local user
> the srvany runs as local user and therefore any sub-process runs as
> local user (I already checked that using sysinternals process
> explorer)
>
> the output of "net use" is interesting: as local user and via task-
> planner it shows the permanent connected drives, running it via
> crusiecontrol it says there are no entries in the list
> but the "net use F: \\server\share password /user:domain\domainuser"
> tells me that the local drive letter is already used (error 85)
>
> it's confusing


This is easy to deconfuse. Run this modified batch file, then
have a look at c:\test.log.
@echo off
echo %date% %time% %UserName% > c:\test.log
net use 1>> c:\test.log 2>>&1
net use F: /delete 1>> c:\test.log 2>>&1
net use F: \\server\share password /user:domain\domainuser 1>> c:\test.log
2>>&1
dir F: 1>> c:\test.log 2>>&1
echo. 1>> c:\test.log

There is one thing you must realise: Making drives mapped in
a foregroud session available to a background session would
be a security violation. Hence drive F: might be mapped in
the foreground and thus not accessible, deletable or reassignable
to your background session. The problem is easily overcome
by using UNC coding for all background processes.


 
Reply With Quote
 
Florian Rosenauer
Guest
Posts: n/a
 
      10th Jun 2008
On 10 Jun., 12:00, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> There is one thing you must realise: Making drives mapped in
> a foregroud session available to a background session would
> be a security violation. Hence drive F: might be mapped in
> the foreground and thus not accessible, deletable or reassignable
> to your background session. The problem is easily overcome
> by using UNC coding for all background processes


Thank you for deconfusing me ;-)
I was not aware of the fact that there are differences between a
foreground and a background session (althought the drive letters are
shared im some curious way). I changed my build process to use UNC and
everything works fine now.

my access method looks like this now:
net use >> log.txt 2>&1
net use \\server\share /delete >> log.txt 2>&1
net use \\server\share password /user:domain\domainuser >> log.txt
2>&1
dir \\server\share >> log.txt 2>&1

Thank you very much!

Kind regards
Florian

 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      10th Jun 2008

"Florian Rosenauer" <(E-Mail Removed)> wrote in message
news:262274e1-c0d9-4b83-b5fb-(E-Mail Removed)...
> On 10 Jun., 12:00, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
>> There is one thing you must realise: Making drives mapped in
>> a foregroud session available to a background session would
>> be a security violation. Hence drive F: might be mapped in
>> the foreground and thus not accessible, deletable or reassignable
>> to your background session. The problem is easily overcome
>> by using UNC coding for all background processes

>
> Thank you for deconfusing me ;-)
> I was not aware of the fact that there are differences between a
> foreground and a background session (althought the drive letters are
> shared im some curious way). I changed my build process to use UNC and
> everything works fine now.
>
> my access method looks like this now:
> net use >> log.txt 2>&1
> net use \\server\share /delete >> log.txt 2>&1
> net use \\server\share password /user:domain\domainuser >> log.txt
> 2>&1
> dir \\server\share >> log.txt 2>&1
>
> Thank you very much!
>
> Kind regards
> Florian
>


Thanks for the feedback. Remember to remove the diagnostic
stuff from your batch file - it serves no useful purpose now.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Control to a UNC share for the Network Service account Oriane Microsoft ASP .NET 3 15th Apr 2009 10:56 AM
Windows service LocalSystem account =?Utf-8?B?V2FsdA==?= Microsoft VB .NET 2 25th Oct 2006 11:56 PM
Network Share\Mapped Drive Access from a windows service =?Utf-8?B?RGF2ZSBTdGV3YXJ0?= Microsoft VB .NET 2 10th Aug 2004 02:24 AM
RE: Add LocalSystem account to a group diasmith [MSFT] Microsoft Windows 2000 Active Directory 0 9th Oct 2003 06:25 PM
Re: How to let a thread run in localsystem account colorknight Microsoft Windows 2000 Applications 5 3rd Sep 2003 06:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:36 PM.