Your .NET and Microsoft technologies specialist in Western Switzerland RSS 2.0
# Tuesday, 16 October 2012

That is something we do almost every time when building workflows. Indeed, at some point in your process, you need to know who belongs to a SharePoint group and you wonder how to get this user’s list. Of course, there is a SharePoint API for that, but when working with Nintex, the only way, if you don’t want to code your custom action, is to use the SharePoint web services. And because it is something that is regularly needed, it made sense to have a “User Defined Action”, just for that. Not that it is difficult to do, but it is quite useful to have a single action that would return the list of user for a given group.

The SharePoint web service that can be used is located at /_vti_bin/usergroup.asmx . One of the method that can be called and which is especially interesting is GetUserCollectionFromGroup that has the following WSDL signature.

POST /_vti_bin/usergroup.asmx HTTP/1.1
Host: myserver
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "
http://schemas.microsoft.com/sharepoint/soap/directory/GetUserCollectionFromGroup"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetUserCollectionFromGroup xmlns="
http://schemas.microsoft.com/sharepoint/soap/directory/">
      <groupName>string</groupName>
    </GetUserCollectionFromGroup>
  </soap:Body>
</soap:Envelope>

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetUserCollectionFromGroupResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/">
      <GetUserCollectionFromGroupResult>string</GetUserCollectionFromGroupResult>
    </GetUserCollectionFromGroupResponse>
  </soap:Body>
</soap:Envelope>

As it can be seen, the web method only needs a “groupName” string parameter and returns a user collection (in other words, an array of users, which is in fact a <Users><User></User></Users> element).

So, to create a useful UDA, the parameters that it should have are :

Parameter Type Direction
The Web Service URL Text Input
The Group Name Text Input
The XML Field you are interested in Text Input
The Collection of Users Collection Output

 

Parameters

The special thing here is the “XML Field your are interested in”. Because I didn’t want to limit the UDA to return either the login or the user first or last name, I decided to leave the decision to the user calling the UDA to choose which field to get in the collection. The format of the parameter is directly tied to the XML outputted by the web service :

<GetUserCollectionFromGroup xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/">
    <Users>
        <User ID="116"
                    Sid="S-1-5-21-2110917764-89557993-3811714100-1138"
                    Name="domain\annem"
                    LoginName="domain\annem"
                    Email="anne.m@domain.com"
                    Notes=""
                    IsSiteAdmin="False"
                    IsDomainGroup="False"
                    Flags="0" />
    </Users>
</GetUserCollectionFromGroup>

If you are interested in the name, the parameter should contain "@Name”, as it is an attribute of the User element. On the other side, if you are interested in the e-mail of the users, then it should contain “@Email”. The image below shows the activities being part of the UDA. Basically, 3 activities are needed : Call Web Service, Query XML, Regular Expression.

GetUsersFromGroupUDA

To configure the Call Web Service activity, enter the URL of the usergroup site’s web service, for example http://myserver/_vti_bin/usergroup.asmx. Enter the user name and password of an account that has the permissions to call the web service in the appropriate text box. A good practice would be to define a protected constant and to select it using the lock icon. Clicking on the Refresh button will list all the methods available from this web service, so, select the “GetuserCollectionFromGroup” one:

CallWebService

Once this is done, the parameters will be listed in the “Web service message” section. You can then replace the different web method arguments by the UDA’s parameters, such as “URL”, “groupName” and “Store result in”. You will end with the following configuration :

CallWebServiceFinal

The next activity, “Query XML” is there to parse the XML response we get from the web method, and to create the collection of users. In the case below, we use the semi-colon as a separator, and we use the “User Field” UDA’s parameter to match the correct attribute using an XSL, the bold part corresponding to the UDA’s parameter :

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:p="http://schemas.microsoft.com/sharepoint/soap/directory/">
    <xsl:template match="p:GetUserCollectionFromGroup/p:Users">
        <xsl:for-each select="p:User">
        <xsl:value-of select="{WorkflowVariable:User Field}"/>;</xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Finally, the “Query XML” should look like :

QueryXML

The very last activity is “Regular Expression”. For a reason that I still have to understand, the collection generated by the “Query XML” activity and stored in the “ParsedGroupUsers” does not behave like a “correct” collection. This is why I use such “Regular Expression”, to split the “ParsedGroupUsers” variable using the semi-colon, and to store the result in the “User Collection” output parameter :

RegularExpression

That’s it !

Publish the User Defined Action and then use this UDA in your workflows.

Tuesday, 16 October 2012 02:06:00 (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Nintex | SharePoint
Ranked #1 as
French-speaking SharePoint
Community Influencer 2013
Currently Reading :
I was there :
I was there :
I was exhibiting at :
I was there :
I was a speaker at :
I was a speaker at :
I was a speaker at
(January 2013 session):
I was a speaker at :
I was a speaker at :
United Nations (UN) SharePoint Event 2011
I was a speaker at :
I was there !
I was there !
I was there !
I was there !
Archive
<2017 October>
SunMonTueWedThuFriSat
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234
Listed On :
Blogroll
[Feed] Weblogger.ch
[Feed] David Chappell :: Weblog
[Feed] RockyH - Security First!
[Feed] The Project Management Podcast™
[Feed] Lunch over IP
[Feed] Intellectual Hedonism
[Feed] Upgrade to Biztalk 2006
[Feed] BizTalk Server Team Blog
[Feed] Eric Cote
[Feed] Mario Cardinal
[Feed] BizTalk Server Performance
[Feed] Julia Lerman Blog - Don't Be Iffy...
[Feed] Dotnet Fox
[Feed] Joel on Software
[Feed] Kevin Lam's WebLog
[Feed] BizTalk 101 - Back to Basics
[Feed] Peter Himschoot's blog
[Feed] Guy Barrette
[Feed] Mark Harrison
[Feed] Chanian, Raj
[Feed] A BizTalk Enthusiast
[Feed] Kevin B Smith's WebLog
[Feed] JABLOG
[Feed] BizTalk Core Engine's WebLog
[Feed] Robert Rijsdijk's BizTalk Server Weblogs
[Feed] Bryant Likes's Blog
[Feed] {CaptainK} - a.k.a Suresh Kumar
[Feed] CaPo's .NET and Enterprise Servers adventures - by Carlo Poli
[Feed] Charles Young
[Feed] Christoph .NET
[Feed] ComputerZen.com - Scott Hanselman's Weblog
[Feed] Console.WriteLine("Hello World");
[Feed] Darrell Norton's Blog
[Feed] Darren Jefford
[Feed] Dot Net Dunk
[Feed] Gilles' WebLog
[Feed] Jan Tielens' Bloggings
[Feed] Lamont Harrington's Blog
[Feed] Lamont Harrington's Blog
[Feed] Luke Hutteman's Weblog
[Feed] Matt Meleski's .Net Blog - The ABC's of .NET
[Feed] Michael Platt's WebLog
[Feed] Mike Holdorf's Blog
[Feed] Mike Taulty's Weblog
[Feed] Neopoleon.com
[Feed] Owen Allen
[Feed] Scott Woodgate's E-Business Outbursts
[Feed] Stephen W. Thomas
[Feed] The Arch Hacker's BizTalk Blog
[Feed] The BizTalk Visionary - BizTalk 2004, SOA and on
[Feed] Trace of Thought (Scott Colestock)
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2017
Yves Peneveyre
Sign In
Statistics
Total Posts: 286
This Year: 0
This Month: 0
This Week: 0
Comments: 18
Themes
Pick a theme:
All Content © 2017, Yves Peneveyre
DasBlog theme 'Business' created by Christoph De Baene (delarou)