Mapping network resources from a service

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Stephane Grobety (Fulgan_at_community.nospam)
Date: 02/08/05


Date: Tue, 08 Feb 2005 09:12:16 -0800

Hello,

I need to do the following: Write a service that will impersonate a
user, map a network ressource to a drive letter, run a process, delete
the mapping and revert to itself.

All these steps I can do wothout problem. But I'm stuck with onother
requirement: the service must run on a terminal server system in
application server mode (actually, a Citrix metaframe server). On that
server, the regular users will also map that drive letter, but to
different ressources (that is how the data is segragated for the users
without having them remember UNC pathes).

All test I've done on my developpement machines seems to lead to the
conclusion that local ressources mapping are global to the system: if I
map a drive from the interractive user, the service fails with a
ERROR_ALREADY_ASSIGNED code. Yet terminal service, in application mode,
has no problem with different users mapping different network resources
to the same local resource.

How can I overcome this difficulty. Have I missed a step in setting up
the user context from my service application ?

What I do is:

Call LogonUser
Call ImpersonateLoggedOnUser
Call WNetAddConnection2
run my process
call WNetCancelConnection2
Call RevertToSelf
Call CloseHandle on the logon handle.

Thanks,
Stephane



Relevant Pages

  • Re: How to mount remote shares for all users?
    ... Try to logon to the server as user X and map a remote share to drive letter ...
    (microsoft.public.windows.server.general)
  • Mapping [WILDPACKET]
    ... I need to map a drive letter to users home folder and printer on the same ... I need to disconnect the existing X: Drive and then reconnect to same ... and also map to the shared printers on this server. ...
    (microsoft.public.scripting.vbscript)
  • How to read the server host name from a mapped network drive?
    ... for our project, the business wants to map a link to a resource (*.doc, ... to find out the server name. ... given a drive letter from an user input, ... Client machines run Windows XP, ...
    (comp.lang.java.programmer)
  • Re: Map drives fails
    ... > I am having a perplexing problem, I have a SBS 2003 Server working very ... > I want to map a network drive letter from the ... > SBS or another other PC on the network to the Full 2003 Server, ...
    (microsoft.public.windows.server.general)
  • Re: hiding the backend
    ... Don't map a drive letter to that location. ... The point is that if you use Windows Explorer and browse to that ... when browing the network. ...
    (microsoft.public.access.security)