PRB: WNetGetUser Does Not Fail on Win95

Last reviewed: September 12, 1997
Article ID: Q173620
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with: - Microsoft Windows 95

SYMPTOMS

WNetGetUser always succeeds on Windows 95, no matter what value you include for the lpName parameter. As long as you pass a valid pointer to the string, the function will succeed and will set the lpUserName parameter to the name of the person that logged into the system.

For instance if you call:

   res = WNetGetUser("VERYBADPATHDESCRIPTION", szName, cbName)

The function will return NO_ERROR (Zero) indicating that it was successful, even though there is no drive letter or other path, and the szName parameter will receive the user's logged in name.

According to the documentation the function should return one of two other errors:

   ERROR_NOT_CONNECTED

-or-

   ERROR_NO_NET_OR_BAD_PATH.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

To work around this issue, first test to see if the drive letter or UNC path exists. Use GetDriveType for local drive letters and WNetOpenEnum for UNC paths.

Steps to Reproduce Behavior

   // Link with MPR.LIB

   #include <windows.h>
   #include <stdio.h>
   #include <winnetwk.h>

   void main(int argc, char *argv[])
   {
      TCHAR szName[50];
      DWORD cbName = 50;
      int res;

      if((res = WNetGetUser(argv[1], szName, &cbName)) == NO_ERROR)
         printf("UserName:\t%s\n", szName);
      else
         printf("Error: %d\n", res);
      return;
   }
Keywords          : NtwkWinnet
Version           : 95
Platform          : Win95
Hardware          : x86
Issue type        : kbprb


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 12, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.