Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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)

↑ Back to the top


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.

↑ Back to the top


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

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


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.

↑ Back to the top


Keywords: kbapi, kbautomation, kbprogramming, kbtshoot, kbprb, KB884502

↑ Back to the top

Article Info
Article ID : 884502
Revision : 2
Created on : 9/16/2004
Published on : 9/16/2004
Exists online : False
Views : 312