Adding a user account
To add a user account, you will want to include the following information:
- The name of the account.
- The full name of the user (optional).
- The password (this is optional and defaults to an empty string).
- The connection type that the user will use. This can be concurrent or named; the default is concurrent.
- Whether or not the password expires (the password expires by default).
Once you have this information, you add a new user account in much the same way that you add any other object such as a report. The basic steps in creating a new object are:
- Retrieve the PluginManager and use it to retrieve the appropriate plugin. In this case, the plugin you want is the User plugin.
- Create a new, empty InfoObjects collection using InfoStore.NewInfoObjectCollection.
- Add the plugin to the collection. This creates a new InfoObject that represents a user.
- Set the properties for the new object.
- Commit the object to the APS using the InfoStore's Commit Method.
Example
var PluginMgr = IStore.PluginManager;
var UserPlugin = PluginMgr.PluginInfo("CrystalEnterprise.User");
var NewInfoObjects = IStore.NewInfoObjectCollection();
NewInfoObjects.Add (UserPlugin);
var InfoObjs = NewInfoObjects.Item(1);
var NewUser = InfoObjs.PluginInterface("");
InfoObjs.Title = AccountName;
InfoObj.Description = Description;
NewUser.FullName = UserName;
NewUser.Connection = NamedUser;
NewUser.PasswordExpires = PasswordNeverExpires;
NewUser.ChangePasswordAtNextLogon = MustChangePassword;
NewUser.AllowChangePassword = CannotChangePassword;
NewUser.NewPassword = Password;
IStore.Commit (NewInfoObjects);
Remarks
To retrieve the User plugin, you can use the PluginManager object's PluginInfo property to specify the ProgID of the User plugin: CrystalEnterprise.User. When setting the properties for the new account, two different methods are used.
- When setting the account name, the Title property is used. The Title property is the name of the InfoObject. The Description property is also used. General InfoObject properties such as these can always be accessed directly. For a list of properties supported by the InfoObject, see InfoStore Object.
- The user's full name, connection type, and password expiry are accessed from the User object. To retrieve the user object, use the PluginInterface property with an empty string. This loads the appropriate plugin for that InfoObject, and returns the appropriate object. Once you have retrieved the User object, you can set any of its properties. For a list of properties supported by the User object, see User Object.