RasSetEntryProperties function fails with error 621 when you call the function in a service that is running under a local system account (884502)



The information in this article applies to:

  • Microsoft Windows 2000 Professional
  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Datacenter Server
  • Microsoft Windows Server 2003, Datacenter Edition
  • Microsoft Windows Server 2003, Standard Edition
  • Microsoft Windows Server 2003, Enterprise Edition
  • Microsoft Windows XP Home Edition
  • Microsoft Windows XP Professional

SYMPTOMS

If you call the RasSetEntryProperties function, and you pass the lpszPhonebook parameter as NULL to create a new remote access service entry or to modify an existing entry in a Win32 service that is running under the context of the local system account, you may receive the following error message:
error 621 (ERROR_CANNOT_OPEN_PHONEBOOK)

CAUSE

The lpszPhonebook parameter is a pointer to a null-terminated string that specifies the full path and file name of a phonebook (.pbk) file. If this parameter is NULL, the function uses the current default phonebook file. When you call the RasSetEntryProperties function in a Win32 service that is running under the context of the local system account, and the lpszPhonebook parameter is set to NULL, the function tries to locate the phonebook file in the %Documents and Settings%\LocalSystem folder. However, the %Documents and Settings%\LocalSystem folder does not exist, and you receive the 621 error message.

RESOLUTION

You can pass in the complete path of the All Users remote access phonebook file to the RasSetEntryProperties function to create the entry. The following is the complete path:

%Documents and Settings%\All Users\Application Data\Microsoft\Network\Connections\Pbk\Rasphone.pbk

STATUS

This behavior is by design.

MORE INFORMATION

Steps to reproduce the behavior
  1. Create a Win32 service, and then add the following code to the Win32 service:
    char strEntry[] ="My Network";
    LPTSTR lpszEntry = strEntry;
    RASENTRY rasEntry;
    ::ZeroMemory(&rasEntry, sizeof(rasEntry));
    rasEntry.dwSize = sizeof(rasEntry);
    DWORD dwRV = RasSetEntryProperties(NULL, (char*)lpszEntry,
    					&rasEntry, sizeof(rasEntry), NULL, 0);
  2. Make sure that the Log on account of the service is set to Local System account. You can verify this under Services in Administrative Tools.

Modification Type:MajorLast Reviewed:9/16/2004
Keywords:kbAPI kbAutomation kbProgramming kbtshoot kbprb KB884502 kbAudDeveloper