Microsoft KB Archive/884502

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

Article ID: 884502

Article Last Modified on 9/16/2004

-

APPLIES TO


 * Microsoft Windows 2000 Professional Edition
 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Datacenter Server
 * Microsoft Windows Server 2003, Datacenter Edition (32-bit x86)
 * Microsoft Windows Server 2003, Standard Edition (32-bit x86)
 * Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
 * 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   Create a Win32 service, and then add the following code to the Win32 service: char strEntry[] =&quot;My Network&quot;; LPTSTR lpszEntry = strEntry; RASENTRY rasEntry;
 * ZeroMemory(&rasEntry, sizeof(rasEntry));

rasEntry.dwSize = sizeof(rasEntry); DWORD dwRV = RasSetEntryProperties(NULL, (char*)lpszEntry,                   &rasEntry, sizeof(rasEntry), NULL, 0);  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.

Additional query words: RasSetEntryProperties API RAS phone book entry Win32 Service Local System account

Keywords: kbtshoot kbapi kbprogramming kbautomation kbprb KB884502

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.