NewPassword Method

See Also    Example    Applies To

Changes the password of an existing user account or Microsoft Jet database (Microsoft Jet workspaces only).

Syntax

VOIDNewPassword(LPCTSTR pstrOld,

LPCTSTR pstrNew );

Parameters

Type Argument Description
LPCTSTR pstrOld A pointer to a string that is the current setting of the Password property of the CdbUser or Microsoft Jet 3.x CdbDatabase object.
LPCTSTR pstrNew A pointer to a string that is the new setting of the Password property of the CdbUser or Microsoft Jet 3.x CdbDatabase object.

Remarks

The pstrOld and pstrNew strings can be up to 14 characters long and can include any characters except the ASCII character 0 ( null ). To clear the password, use a zero-length string ("") for newpassword.

Passwords are case-sensitive.

When used from a CdbUser object that is not yet appended to a Users collection, an error occurs. To set a new password, you must either log on as the user whose account you're changing, or you must be a member of the Admins group. The Password property of a CdbUser object is write-only — users can't read the current value.

When used from a Microsoft Jet version 3.0 or later CdbDatabase object, this method offers some security by means of password protection. When you create or open a Microsoft Jet 3.x .mdb file, part of the Connect connection string can describe the password.

If a database has no password, Microsoft Jet will automatically create one by passing a zero-length string ("") for the old password.

Caution If you lose your password, you can never open the database again.

Usage

#include <afxole.h>
#include <dbdao.h>
CdbUser   us;
...
us.NewPassword   (_T("openSesame"),  _T("enterFreely"));