Skip to main content
Nintex Community Menu Bar

Get Worklist item from Server event

  • March 16, 2009
  • 13 replies
  • 27 views

Forum|alt.badge.img+3

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 

 
 

13 replies

Forum|alt.badge.img+9
  • Nintex Partner
  • March 16, 2009

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.


Forum|alt.badge.img+3
  • Author
  • Nintex Partner
  • March 16, 2009

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 ?? 


Forum|alt.badge.img+9
  • Nintex Partner
  • March 16, 2009

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();).


Forum|alt.badge.img+3
  • Author
  • Nintex Partner
  • March 17, 2009

Service account has admin and start rights on this process.

 

The connection is closed after my code sample. Good remarks.

 


Forum|alt.badge.img+9
  • Nintex Partner
  • March 17, 2009
How are you attempting to start this process instance (Workspace, ASP.NET, InfoPath...)? 

Forum|alt.badge.img+3
  • Author
  • Nintex Partner
  • March 17, 2009

With the workspace (Instances...Start new instance).

It's a proof of concept so i didn't develop user interface 


Forum|alt.badge.img+9
  • Nintex Partner
  • March 17, 2009
And you're logged into Workspace as the K2 Service Account (t will show in the middle of the page header as "Logged in as"?

Forum|alt.badge.img+3
  • Author
  • Nintex Partner
  • March 17, 2009
I checked it. It's OK.

Forum|alt.badge.img+9
  • Nintex Partner
  • March 17, 2009
What do you mean by "it's OK"... things are working as expected or you're logged into Workspace as the service account and you are getting this when kicking off the process?

Forum|alt.badge.img+3
  • Author
  • Nintex Partner
  • March 17, 2009

oops sorry.

I'm logged into Workspace as the service account and i always have my problem.


Forum|alt.badge.img+9
  • Nintex Partner
  • March 17, 2009
If you haven't done so already, I'd consider opening a support ticket on this one as I think it may require some digging through logs and configurations to determine what is causing that error.  That is not a common one.

Forum|alt.badge.img+3
  • Author
  • Nintex Partner
  • March 17, 2009

Thank for your help Bob.

I will open a support ticket. 


Forum|alt.badge.img
  • May 11, 2009

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.