CreateUser Method

       

Creates a new CdbUser object (Microsoft Jet workspaces only).

Syntax

CdbUserCreateUser(LPCTSTR pstrName = NULL,

LPCTSTR pstrPID = NULL,

LPCTSTR pstrPassword = NULL);

Parameters

Type Argument Description
LPCTSTR pstrName Optional. A pointer to a string that uniquely names the new CdbUser object. See the Name property for details on valid CdbUser names.
LPCTSTR pstrPID Optional. A pointer to a string containing the personal identifier (PID) of a user account. The PID must contain from 4 to 20 alphanumeric characters. See the PID property for more information on valid personal identifiers.
LPCTSTR pstrPassword Optional. A pointer to a string containing the password for the new CdbUser object. The password can be up to 14 characters long and can include any characters except the ASCII character 0 ( null ). See the Password property for more information on valid passwords.

Remarks

If you omit one or more of the optional arguments when you use the CreateUser method, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the object, you can alter some, but not all, of its property settings. See the PID, Name, and Password property topics for more details.

If pstrName refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove a CdbUser object from the Users collection, use the Delete method on the collection.

Usage

#include <afxole.h>
#include <dbdao.h>

CdbDBEngine       dben;
CdbWorkspace      ws;
CdbUser               usr;
CdbGroup         grp;
...   
ws = dben.Workspaces[0L];
usr = ws.CreateUser(_T("JohnDoe"), _T("Accountant"), _T("ACCT001")); 
grp = ws.CreateGroup(_T("Accountants"), _T("DEPT_01_99")); 
grp.Users.Append(usr);
usr.Groups.Append(grp);