Hi
I need to know the number of task items of a user in a server event. I know user's login.
Need i impersonate ?
Can i use Connection object in a server event ?
Thanks for your replies
Hi
I need to know the number of task items of a user in a server event. I know user's login.
Need i impersonate ?
Can i use Connection object in a server event ?
Thanks for your replies
You can utilize SourceCode.Workflow.Client. Since you're within the process, it will connect as the K2 service account. If it isn't already, grant the Service Account "Impersonate Permissions" within K2 Workspace > Workflow Server > Server Rights. Once you make the connection as the service account you can then do a Connection.Impersonate() and then call the worklist methods. This topic is covered in more detail, with code sample, within the product documentation (specifically, K2 Developer Reference > Users > Impersonation > Using User Rights Impersonation).
Please be mindful that worklist retrieval can be a very resource intensive operation (depending on lots of things like volumes, dynamic roles...) which could potentially affect workflow execution.
HTH.
Thank you Bob
I tried this code in my server event :
Connection server = new Connection();
server.Open("K2Server");
server.ImpersonateUser(@"domainuserLogin");
try
{
int itemsCount = server.OpenWorklist().TotalCount;
}
finally
{
server.RevertUser();
}
When i start a new instance of my process, i obtain this error in K2 Console log :
Error 2025 Error Marshalling SourceCode.Security.UserRoleManager.Runtime.UserRoleManagerServer.FindGroups, DirectorySearcher returned no results
Ideas ??
Are you sure that the identity under which you are attempting to start the process instance has Start or Admin rights within K2 for that specific process?
Also, on an unrelated note, within the server event code, you'll want to make sure you close the connection (server.Close();).
Service account has admin and start rights on this process.
The connection is closed after my code sample. Good remarks.
With the workspace (Instances...Start new instance).
It's a proof of concept so i didn't develop user interface
oops sorry.
I'm logged into Workspace as the service account and i always have my problem.
Thank for your help Bob.
I will open a support ticket.
DirectorySearcher returned no results normally indicate that the user was not found.
Have a look in your ADUMError.txt file. If it says something like:
GetUser(DomainName$) OR
GetUser(NT AUthorityANONYMOUS LOGON)
it means it's trying to authenticate as a machine or as an anonymous user. Have a look at your AppPool settings (it it's from a web site) or your kerberos settings.
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.