tags:

views:

23

answers:

1

The step is: I have been running a service program with UAC for mapping network drive using function WNetAddConnection2, then it was successful.

I ran another program with privilege of administrator(run as administrator) to call function GetFileAttribute to get network drive's attribute, however, it was returned 0xffffffff and error code was 3(Doesn't find the special path).

I also have tried create file on network drive, but it was still failed.

Could you please help me to solve this problem?

Thanks a lot.

A: 

In NT, a "network drive" is a symbolic link from the MS-DOS filesystem namespace to a UNC path. Those symbolic links are maintained per logon session. This also means that an Administrator has its own set of symbolic links.

The solution is to call WNetAddConnection2 in each logon session that needs to access the particular UNC network path as a drive letter.

This is documented on the MSDN page :

On Windows Server 2003 and Windows XP, the WNet functions create and delete network drive letters in the MS-DOS device namespace associated with a logon session because MS-DOS devices are identified by AuthenticationID (a locally unique identifier, or LUID, associated with a logon session.) This can affect applications that call one of the WNet functions to create a network drive letter under one user logon, but query for existing network drive letters under a different user logon.

MSalters