INFO: Services and Redirected Drives

ID: Q180362


The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API), used with:
    • Microsoft Windows NT 4.0
    • Microsoft Windows 2000


SUMMARY

A service should not use the WNetXXXXXXX APIs to remove or query any redirected drives not established by it. Although the WNetXXXXXXX APIs may return successfully, the results will be incorrect. Redirected drives are tracked by the system on a per-user basis based on the user's Logon Security Identifier (SID). Instead, processes running in different security contexts that must share a remote resource should use the Universal Naming Convention (UNC) name.


MORE INFORMATION

When the system establishes a redirected drive, it is stored on a per-user basis. Only the user himself will be able to manipulate the redirected drive. The system keeps track of redirected drives based on the user's Logon SID. The Logon SID is a unique identifier for the user's Logon Session. It is possible to have the same user logged on to the same computer but have different logon sessions.

Drive letters are global to the system. All users on the system share the letters A-Z. Each user does not get his or her own set of drive letters. This means a user can access the redirected drives of another user as long as he or she has proper security access.

If a user attempts to redirect a drive letter used by another user, such as WNetAddConnection2(), the error ERROR_ALREADY_ASSIGNED will be returned. Although the redirected drive is global to all users, only the user who established it can manipulate it. Another example is if a user attempts to remove or query information on a redirected drive established by a different user. The APIs WNetGetConnection() and WNetCancelConnection2() will return

ERROR_NOT_CONNECTED


If a user attempts to enumerate the list of redirected drives through WNetOpenEnum() and WNetEnumResource(), the APIs only list redirected drives established by that user. Drives redirected by other users will not be visible.

Windows NT File Manager and Windows NT Explorer can see all the redirected drives because they call GetDriveType() on each drive and they display an icon for each drive found. Windows NT File Manager and Windows NT Explorer create an icon for redirected drives created by all users because drive letters are global to the system. However, the interactive user cannot use Windows NT File Manager or Windows NT Explorer to disconnect the drive because the drive was created by a different user.

If a service is running in the LocalSystem security context only that Service or another process running in the LocalSystem account can call WNetCancelConnection2() to disconnect the drive. Note that all processes running in the LocalSystem account are running in the same logon session.

Additional query words: mapped

Keywords : kbAPI kbFileIO kbKernBase kbNTOS400 kbWinOS2000 kbService kbDSupport kbGrpKernBase
Version : winnt:4.0
Platform : winnt
Issue type : kbinfo


Last Reviewed: January 10, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.