Related Topics
User Class
This object represents a user in a Form instance. An instance is a completed Form, or one that is currently being edited.
When developing Form scripts (in the various callback methods such as BP_Event), you are automatically given an instance of the “current” user with the CurrentUser variable.
Properties
PROPERTY NAME |
DATA TYPE |
DESCRIPTION |
---|---|---|
AuthType |
Code Enum |
The type of user.
|
AutoDST |
Boolean |
Is DST enabled for user? |
AvgLoginSeconds |
Integer |
The average number of seconds the user remains logged in. |
Company |
tblTaskList |
The optional company associated with this user |
Culture |
tblTaskList |
A string value containing the User's culture information derived from the .NET CultureInfo Class. |
CustomDate |
DateTime |
Optional custom date/time associated with user |
CustomNumber |
Decimal |
Optional custom number associated with user |
CustomString |
tblTaskList |
Optional custom string associated with user |
CustomString2 |
tblTaskList |
Optional second custom string associated with user |
Delegate |
User Object |
A different user to which the user delegates (if null, the user has no delegate) |
Dept |
tblTaskList |
The optional department associated with this user |
Description |
tblTaskList |
The optional description associated with this user |
Disabled |
Boolean |
A Boolean value that returns "true" if the user is disabled. |
DisplayString |
tblTaskList |
Returns either the UserName if configured, or the UserID |
Domain |
tblTaskList |
Optional domain if user is a Windows user |
|
tblTaskList |
Email address of user |
ExternalGUID |
tblTaskList |
The optional external unique ID associated with this user |
Groups |
List Object |
The list of groups to which the user belongs, returned as List<Group>. If you need to check whether a large number of users are in a specific group, it may be more efficient to use the |
ImpersonatedBy |
User Object |
If the user is being impersonated, this will be a string containing the name of the impersonating user. |
LastActivity |
DateTime |
Timestamp of last activity for user |
Locked | Boolean | A Boolean value that returns "true" if the user account is locked. |
NumLogins |
Integer |
The number of times the user has logged in. |
Office |
String |
The optional office associated with this user |
Phone |
String |
The optional phone number associated with this user |
SessionObjects |
Dictionary Object |
Returns a dictionary of attributes that can associated with this user while logged in, returned as a |
Tasks |
List Object |
Returns the list of Tasks for the user, returned as a |
TimeZone |
String |
Time zone of user |
Title |
String |
The optional title associated with this user |
UID |
String |
The internal ID of the user |
UserID |
String |
The unique string to identify the user |
UserName |
String |
The "friendly" name of the user (for display) |
Example
// Setting a variable to the current username
var cUser = CurrentUser.UserName;
Methods


This method enables the ability to add or remove a UID from the list of shared delegate users for a user.
Parameters
pGrantAccessToUID: The UID to add to the shared delegation.
Returns
Boolean: True if the operation succeeds.
Example
// Add a user to shared delegation
CurrentUser.AddSharedDelegate("UID");


This method adds the user to the specified group. This is an overloaded method with the following possible declarations:
public void AddToGroup(Group Group)
public void AddToGroup(string GID)
Parameters
GID: The ID of the group to which to add the user.
Group: The actual group object to which to add the user.
Returns
None
Example
var oUser = User.GetUserByUserID(bp, "UID");
var oGroup = Group.GetGroupByName(bp, "GroupName");
// The following two calls do the same thing (add "oUser" to "oGroup")
oUser.AddToGroup(oGroup); // Call with the Group object
oUser.AddToGroup(oGroup.GID; // Call with the Group ID


This method adds the user to the specified partition.
Parameters
Partition: The Partition object to which to add the user.
Returns
Boolean: True if the operation succeeds.
Example
// Create a user, and force the user to change the password after login
var oUser = User.CreateUser(bp, "NewUID", "new@acme.com", "New User",
"TEMP_PASSWORD",true);
// Add the new user to a partition
oUser.AddUserToPartition(Partition.GetPartition(bp, "Partition Name"));


This method adds the user to the specified profile.
Parameters
Profile: The name of the profile to which to add the user.
Returns
Boolean: True if the operation succeeds.
Example
// Create a user, and force the user to change the password after login
var oUser = User.CreateUser(bp, "NewUID", "new@acme.com",
"New User", "TEMP_PASSWORD",true);
// Add the new user to a profile
oUser.AddUserToProfile("ProfileName");


This method will create a user object for the specified ID.
Parameters
BP: The bp environment.
UserID: The User ID to create.
Email: The email address of the new user.
UserName: The name of the new user.
Password: The initial password of the new user.
MustChangePassword: If set to true, the new user must change the password after logging in.
AuthType: Added in v5.44.500, this parameter takes one of the User.eAuth enum types to specify the authorization type for the user.
Returns
User: A user object representation of the new user.
Example
// Create a user, and force the user to change the password after login
var oUser = User.CreateUser(bp, "NewUID", "new@acme.com",
"New User", "Temp_Password", true);


This method will create a user object for the specified ID. The user object is an external user which can only be signed in via an external authentication system. This is an overloaded method with the following possible declarations:
public static User CreateExternalUser(bp BP, string UserID,
string Email, string UserName)
public static User CreateExternalUser(bp BP, string UserID,
string Email, string UserName,
Defines.eAuth UserType)
public static User CreateExternalUser(bp BP, string UserID,
string Email, string UserName,
string GUID,
Defines.eAuth UserType)
public static User CreateExternalUser(bp BP, string UserID, string Email,
string UserName, string GUID,
string Domain,
Defines.eAuth UserType)
Parameters
BP: The bp environment.
UserID: The User ID to create.
Email: The email address of the new user.
UserName: The name of the new user.
UserType: Optional type of user.
GUID: Optional Unique identifier for the user.
Returns
User: A user object representation of the new user.
Example
// Create a SAML user
var oUser = User.CreateExternalUser (bp, "NewUID", "new@acme.com",
"New User", User.eAuth.SAML);


This method will decode an LDAP name string to only return the "name" part. This is typically used for groups.
Parameters
Name: The LDAP Name string.
Returns
String: The "name" portion of the LDAP string.
Example
string name = DecodeLDAPName("cn=ABC");


This method will remove the User from the system.
BP Logix strongly recommends that users be disabled, not deleted. Deleting a user will delete all of their system history as well, including all process partitipation.
Parameters
BP: The BP Logix environment.
UserUID: The User UID of the User to delete.
Returns
Boolean: True if the operation succeeds.
Example
bool deleted = DeleteUser(bp, "USERUID");


This method will disable the specified user's account and cancel the user in any active process tasks.
Parameters
None
Returns
Boolean: True of the operation succeeds.
Example
var oUser = User.GetUserByUserID(bp, "UID");
oUser.DisableUser();


This method will disable the ability to send email to a specified user.
Parameters
None
Returns
Boolean: True of the operation succeeds.
Example
var oUser = User.GetUserByUserID(bp, "UID");
oUser.DisableUserEmail();


This method will enable a Process Director User. This is an overloaded method with the following possible declarations:
public bool EnableUser()
public bool EnableUser(bool pEnable)
[Deprecated]
Parameters
pEnable [Optional]: Setting this parameter to "True" will enable the user, and setting it to "False" will disable the user. The method that uses this parameter has been deprecated, but remains in the product for backward compatibility.
Returns
Boolean: True of the operation succeeds.
Example
var oUser = User.GetUserByUserID(bp, "UID");
oUser.EnableUser();


This method will enable the ability to send email to a specified user.
Parameters
None
Returns
Boolean: True of the operation succeeds.
Example
var oUser = User.GetUserByUserID(bp, "UID");
oUser.EnableUserEmail();


This method will get a user object from the specified external ID. For instance, Active Director users user the SID as the unique external identifier.
Parameters
BP: The bp environment.
ExtID: The unique external ID of the user to retrieve.
Returns
User: A user object representation of the user.
Example
var oUser = User.GetUserByExtID (bp, userprincipal.Sid.ToString());


This method will get a user object from the specified UserID.
Parameters
BP: The bp environment.
pUID: The UID of the user to retrieve. This is the internal ID used by Process Director.
Returns
User: A user object representation of the user.
Example
// Normally not used directly
var oUser = User.GetUserByID(bp, "UID");


This method will get a user object from the specified ID. This is an overloaded method with the following possible declarations:
public static User GetUserByUserID(bp BP, string pUserID)
public static User GetUserByUserID(bp BP, string pUserID,
Defines.eAuth AuthType)
Parameters
BP: The bp environment.
pUserID: The ID of the user to retrieve.
AuthType: An optional Defines.eAuth
object that defines the user's authorizations, i.e. User.eAuth.Windows, User.eAuth.BuiltIn, etc.
Returns
User: A user object representation of the user.
Example
// Normally not used directly
var oUser = User.GetUserByUserID(bp, "UID", User.eAuth.BuiltIn);


This method will get a user object from the specified UID or UserID. This is an overloaded method with the following possible declarations:
public static User GetUserByUserID(bp BP, string pUser)
public static User GetUserByUserID(bp BP, string pUser,
Defines.eAuth AuthType)
Parameters
BP: The bp environment.
pUser: The UID or UserID of the user to retrieve.
AuthType: An optional Defines.eAuth object that defines the user's authorizations, i.e. User.eAuth.Windows, User.eAuth.BuiltIn, etc.
Returns
User: A user object representation of the user.
Example
// Normally not used directly
var oUser = User.GetUserByUserID(bp, "UID");


This method enables you to import a batch of users from an Excel spreadsheet.
Parameters
BP: The BP class.
DID: The Document ID of the Excel file in the Content List.
SheetName: The sheet name in the Excel file that contains the list of users.
Returns
String: The result of the import operation.
Example
// Import the users in the "Users.XLSX" file in the sheet named "Sheet1"
var DID = ContentObject.GetObjectByPathName(bp, "PartitionName",
"/Users.XLSX");
var RES = BPLogix.WorkflowDirector.SDK.User.ImportUsersFromExcel(bp,
DID.ID, "Sheet1");


This method checks if the user exists in the specified group.
Parameters
GID: The ID of the group in which to test the user.
Group: The actual group object in which to test the user.
Returns
Boolean: Whether or not the user exists in the specified group.
Example
var oUser = User.GetUserByUserID(bp, "UID");
var oGroup = Group.GetGroupByName(bp, "GroupName");
// The following two conditionals test the same thing (is "oUser"
// in "oGroup")
if(oUser.InGroup(oGroup))
{
// Do action
}
if(oUser.InGroup(oGroup.GID))
{
// Do action
}


This method will take a UID or UserID list in string format or in a DataItem object and convert it to a normalized List object. This is an overloaded method with the following possible declarations:
public static List<User> NormalizeUserList(bp BP, string pUserList)
public static List<User> NormalizeUserList(bp BP, string pUserList,
bool ReturnNullOnInvalid)
public static List<User> NormalizeUserList(bp BP, ref DataItem pUsers)
public static List<User> NormalizeUserList(bp BP, ref DataItem pUsers,
bool ReturnNullOnInvalid)
Parameters
BP: The bp environment.
pUserList: A string containing a comma-separated UID or UserID list of users.
pUsers: A DataItem object containing a list of UIDs or UserIDs.
ReturnNullOnInvalid: A boolean value the determine whether to return a null object if the list is invalid. True will return the null on onvalid.
Returns
List: A List object containing the UIDs or UserIDs.
Example
// Normally not used directly
List oUsers = NormalizeUserList(bp, "UID1,UID2,UID3");


This method will remove the User the specified group.
Parameters
GID: The ID of the group from which to remove the user.
Group: The actual group object from which to remove the user.
Returns
None
Example
var oUser = User.GetUserByUserID(bp, "UID");
var oGroup = Group.GetGroupByName(bp, "GroupName");
oUser.RemoveFromGroup(oGroup);


This method will remove a User from a shared delegation.
Parameters
pRemoveUID: The UID of the user to remove from shared delegation.
Group: The actual group object from which to remove the user.
Returns
Boolean: True if the operation succeeds.
Example
// Remove a user from shared delegation
CurrentUser.RemoveSharedDelegate("UID");


This method will replace a Process Director user with a specified replacement user.
Parameters
ReplacementUID: The UID of the replacement user.
Returns
Boolean: True of the operation succeeds.
Example
var oUser = User.GetUserByUserID(bp, "UID");
oUser.ReplaceWithUser("ReplacementUID");


This method changes or sets the current user context.
Parameters
BP: The BP Logix environment.
UID: The string UID or UserID of the user.
Returns
Boolean: True if the operation succeeds.
Example
bool curr = SetCurrentUserContext("UID");


This method will update the user object in the database with any changes made to the object’s properties (e.g. “UserID”, “UserName”, etc.)
Parameters
None.
Returns
Boolean: True if the operation succeeds.
Example
// Select a user
var oUser = User.GetUserByUserID(bp, "UID");
// Change the user's Company name
oUser.Company= "MyCompany";
// Update the user
oUser.UpdateUser();


This method enables you to check to see if a user exists.
Parameters
BP: The BP Logix environment.
pUserID: A string UserID.
Optional Parameters
pAuthType: A User.AuthType object specifying the authorization type (Unknown, BuiltIn, Windows, etc.). If this parameter is omitted, then Process Director will default this parameter to User.eAuth.BuiltIn.
Returns
Boolean: True if the user exists.
Example
bool exists = UserExists(bp, "UID", User.eAuth.BuiltIn);
Documentation Feedback and Questions
If you notice some way that this document can be improved, we're happy to hear your suggestions. Similarly, if you can't find an answer you're looking for, ask it via feedback. Simply click on the button below to provide us with your feedback or ask a question. Please remember, though, that not every issue can be addressed through documentation. So, if you have a specific technical issue with Process Director, please open a support ticket.