How do I populate users with members of Destination Queue

  • 19 February 2004
  • 12 replies
  • 0 views

Badge +3
I want to have a drop down list box on a smartform that contains all the users in a destination queue.

The user will then select a user, and the next activity will be assigned to the chosen user.

What is the best way to do this?

Alternatively, if this is not possible, is it possible to list in the Drop down, all users of a certain AD Group

12 replies

Badge +4
Add the ADUM.dll and the Sourcecode.K2UMI.dll to the .Net Smartforms web references. The files are located in the C:Program FilesK2.net 2003Bin dir. Remeber to change the AD Group Name "ADGroupName" to an existing group in your AD Structure.

Use the following code to populate the K2 DropdownListBox:

Dim ADUM As New ADUM.K2UserManager
Dim Users As SourceCode.K2UMI.IK2Users
Dim User As SourceCode.K2UMI.IK2User

'Clear
K2cboAD.Items.Clear()

If Trim(txtGroup.Text) <> "" Then
Users = ADUM.FindSecurityUsers("ADGroupName", , , , )
If Not Users Is Nothing Then
For Each User In Users
K2cboAD.Items.Add(User.Name.ToString)
Next
End If
End If


In the Destination Rule where you see the following code, replace with field value that's linked to your K2 DropdownListBox Value:

'== sendto
K2.Destinations.Add(DestinationType.User, K2.ProcessInstance.DataFields.Item("FieldName").Value)

There you go...
Badge +7
David,
thanks for this excellent post! :)
Badge +3
Many thanks David, excellent work
Badge +1
Hi,

i had use these code in my k2.it was ok.
But when i used it in K2 workflow service pack 1, it failled. It was nothing inside the [users].

any ideas?

Thanks
Badge +2
I had the same experience in code searching for a specific user.

What I found was that the user's name is now retruned as DOMAINUsername and not just Username as in Hotfix 2

Thus I had to slipt the DOMAIN and username first before I could search for the user with Username only

Tersia
Badge +3
Hi.

I rewrited previous example to C#, to console application but it actually doesn't work very well. That means, method FindSecurityUsers returns me always all users in AD, not only these that are in specified group.

");
Console.ReadLine();


But, when I'm in K2 Studio and I'm adding the same group to destination rule, it extraxts correctly only users from this group. So, there definitely must be something wrong in my code.

Does anyone have an idea what am I doing wrong?

Thanx in advance.
Badge +11
The ADUM.dll is for internal K2.net use only and not meant for other custom solutions. This library needs certain startup/configuration parameters in order to function properly. To get a list of AD group members, you should use the standard .NET DirectoryServices class.

Regards,
Ockert
Badge +3
5, maximum 10 minutes ago I finished coding a two methods which will return a list of user's groups and list of groups' users. This methods of course use the DirectoryServices.

Ockert, it must really be a deduction :)

OK, thank you anyway for reply.
Badge +3
Hi K2 Experts,

I'm interested in getting all the users in a particular Destination Queue. I tried but failed to find ADUM.dll on my hard drive as per this suggestion in the thread:

"Add the ADUM.dll and the Sourcecode.K2UMI.dll to the .Net Smartforms web references. The files are located in the C:Program FilesK2.net 2003Bin dir."

Where can I obtain ADUM.dll?

I'm using 3.5140.1.0.

Thanks
Badge +11
It should be in the specified directory on a machine or server running K2.net SERVER. If it's not there, your K2Server will not start up.

Regards,
Ockert
Badge +3
Thanks Ockert,

I suppose that it would not be a good idea to copy ADUM.dll from the server to my development machine to use with a SmartForm application.

Thanks for the reply.
Badge +11
Should not be a problem - as long as it is the same version as the one running on the server.

Cheers,

Reply