Introduction
Developers can access and retrieve all information about users and their groups in the engine using Aspose.Workflow at runtime. It allows developers to explore the information about groups and users before taking any desired action on them.
Aspose.Workflow provides an interface, IUserGroupManager that provides almost everything to deal with users or their groups. An object of IUserGroupManager can be created by using the UserGroupManager property of IEngine interface. And IEngine can be instantiated by using the Instance.Engine property of EngineManager class.
Retrieving Information About All Groups
To access and retrieve information about all User Groups present in Aspose.Workflow engine, developers can call GetAllGroupNames method of IUserGroupManager object. This method returns the names of all groups available in the engine.
After receiving the names of all groups, developers can iterate through these group names and create the instance of any group by calling the GetGroup method of IUserGroupManager object. GetGroup method takes the group name and returns a reference to that group as an object of IGroup , where IGroup is an interface that represents a group in Aspose.Workflow.
Once an object of IGroup is obtained, you can easily use the properties offered by the IGroup to retrieve all information associated to that group. For example, you can use the following two properties of IGroup:
- SubGroups , provides the names of all sub groups present in the specified group
- Users , provides the names of all users associated to the specified group
Please review the example given below to learn the usage of this feature.
Example:
[C#]
//Create an instance of IUserGroupManager interface
IUserGroupManager userGroupManager = engine.UserGroupManager;
//Retrieving and iterating through all group names present in the engine
foreach(string groupName in userGroupManager.GetAllGroupNames())
{
//Create an instance of each specific group using its group name
IGroup group=userGroupManager.GetGroup(groupName);
//Retrieve the names of all sub groups present in the specified group
string[] subGroupsNames=group.SubGroups;
//Retrieve the names of all users present in the specified group
string[] usersNamesInGroup=group.Users;
}
[VB.NET]
'Create an instance of IUserGroupManager interface
Dim userGroupManager As IUserGroupManager = engine.UserGroupManager
'Retrieving and iterating through all group names present in the engine
Dim groupName As String
For Each groupName In userGroupManager.GetAllGroupNames()
'Create an instance of each specific group using its group name
Dim group As IGroup = userGroupManager.GetGroup(groupName)
'Retrieve the names of all sub groups present in the specified group
Dim subGroupsNames() As String = group.SubGroups
'Retrieve the names of all users present in the specified group
Dim usersNamesInGroup() As String = group.Users
Next
Retrieving Information About All Users
To access and retrieve information about all Users present in Aspose.Workflow engine, developers can call GetAllUserNames method of IUserGroupManager object. This method returns the names of all users available in the engine.
After receiving the names of all users, developers can iterate through these user names and create the instance of any user by calling the GetUser method of IUserGroupManager object. GetUser method takes the user name and returns a reference to that user as an object of IUser , where IUser is an interface that represents a user in Aspose.Workflow.
Once an object of IUser is obained, you can easily use the properties offerd by the IUser to retrieve all information about that user. For example, you can use the following properties of IUser:
- FirstName , provides the first name of the specified user
- LastName , provides the last name of the specified user
- Email , provides the email address of the specified user
- Groups , provides the names of all groups to which a specified user belongs
These features of Aspose.Workflow are implemented below in the example.
Example:
[C#]
//Create an instance of IUserGroupManager interface
IUserGroupManager userGroupManager = engine.UserGroupManager;
//Retrieving and iterating through all user names present in the engine
foreach(string userName in userGroupManager.GetAllUserNames())
{
//Create an instance of each specific user using its user name
IUser user=userGroupManager.GetUser(userName);
//Retrieve the first name of the specified user
string firstName=user.FirstName;
//Retrieve the last name of the specified user
string lastName=user.LastName;
//Retrieve the email address of the specified user
string email=user.Email;
//Retrieve the names of all those groups to which a user belongs
string[] userGroups=user.Groups;
}
[VB.NET]
'Create an instance of IUserGroupManager interface
Dim userGroupManager As IUserGroupManager = engine.UserGroupManager
'Retrieving and iterating through all user names present in the engine
Dim userName As String
For Each userName In userGroupManager.GetAllUserNames()
'Create an instance of each specific user using its user name
Dim user As IUser = userGroupManager.GetUser(userName)
'Retrieve the first name of the specified user
Dim firstName As String = user.FirstName
'Retrieve the last name of the specified user
Dim lastName As String = user.LastName
'Retrieve the email address of the specified user
Dim email As String = user.Email
'Retrieve the names of all those groups to which a user belongs
Dim userGroups() As String = user.Groups
Next