cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to determine if user is in group?


I have a NW2010 workflow, and I'd like to base a conditional in the workflow on if the user is a member of a particular SharePoint group. How would I go about accomplishing this?

Labels: (2)
Tags (2)
Reply
15 Replies
Workflow Hero

Re: How to determine if user is in group?

You can put the members of a group in a collection variable and check to see if the user is in that variable.

0 Kudos
Accept as Solution Reply
Not applicable

Re: How to determine if user is in group?

I found the solution a few minutes ago: http://blog.cube4.com.au/?p=953

Accept as Solution Reply
Not applicable

Re: How to determine if user is in group?

Sorry to bother, but the link to the solution is broken and I am in the same situation.

Can you please post the solution? Or point me out to the right direction?

Thank you!

0 Kudos
Accept as Solution Reply
Not applicable

Re: How to determine if user is in group?

I see that URL is indeed down. So the fix goes like this.

Create workflow variable varUserGroupXML type=Multiple Lines of Text

Create workflow variable varUserGroupNames type=Collection

Create workflow variable varIsInGroup type=Yes/No

To make it easy to reuse, create an Action Set action, and label it "Is user in group?"

Put the following within that Action Set.

Call Web Service action. Configure it as follows:

     URL: Web_URL/_vti_bin/UserGroup.asmx. Supply necessary Username/PW credentials.

  • Web Method: GetGroupCollectionFromUser
  • Editor Mode: SOAP builder
  • userLoginName(string): Initiator
  • Web Service Output: Specify elements "../m:GetGroupCollectionFromUserResult" > varUserGroupXML

Use the Run Now to verify things work.

Query XML action. Configure as follows:

  • XML Source: XML
  • XML: {WorkflowVariable:varUserGroupXML}
  • Output 1: Process using: XPath.
    /defaultNS:GetGroupCollectionFromUser/defaultNS/Groups/DefaultNS:Group/@Name
  • Return Results as: text
  • store result in : varUserGroupNames

Collection Operation action. Configure as follows:

  • Target collection: varUserGroupNames
  • Exists: checked
  • Value: Value (selected from dropdown menu) - (the group name you are interested in) typed in text input
  • Store result in: varIsInGroup

Now, the value of varIsInGroup will be a yes/no.

You could probably make this cleaner by putting the group name to search for in a workflow variable as well.

So that's how my actual workflow looks. I wished the URL http://blog.cube4.com.au/?p=953 with the actual documentation worked. May this be sufficient to get you steered in the right direction.

Accept as Solution Reply
Not applicable

Re: How to determine if user is in group?

Thank you very much Alan,

Yes that was very helpful. I've almost completed it.

My only problem now is that the XML returned by the web services doesn't seem to fit in the variable varUserGroupXML, even though it is a multiple lines of text variable. I've been debbuging it using the  "log in the history list" box and it seems it only stores a part of it:

<GetGroupCollectionFromUser xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/"><Groups><Group ID="7" Name="ProcesosUsers" Description="Use este grupo para conceder a los usuarios permisos de colaboración en el sitio de SharePoin

I would try to fix it. But any ideas will be welcome

Just one thing, the call to the web service you gave me needs one "_" before "vti_bin...", jut in case anyone needs to use it:

      URL: Web_URL/_vti_bin/UserGroup.asmx

Thank you again

0 Kudos
Accept as Solution Reply
Not applicable

Re: How to determine if user is in group?

I fixed it!

I had an error in the Query XML box, there was no error with the varUserGroupXML.

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: How to determine if user is in group?

If you can, change the answer to your longer explanation. And thank you for posting it. To really make this reusable, I would take the action set and drop it into a UDA.

Accept as Solution Reply
Not applicable

Re: How to determine if user is in group?

Thanks for pointing that out. i updated it to show _vti_bin. And I'm glad the solution worked for you. I'd love to take credit for it, all I did was copy and paste what somebody else developed.

0 Kudos
Accept as Solution Reply
Not applicable

Re: How to determine if user is in group?

Hi Alan

First of all thanks for your post. It helped me alot.

Just a minor correction is that your XPath Output 1 section have a capital D in DefaultNS:

/defaultNS:GetGroupCollectionFromUser/defaultNS/Groups/DefaultNS:Group/@Name

but should be:

/defaultNS:GetGroupCollectionFromUser/defaultNS/Groups/defaultNS:Group/@Name

I point it out just in case somebody would get the same errors as I did :/

Once again thank you for the post tho. As I said it is just a minor hehe

Kind regards

Michael

0 Kudos
Accept as Solution Reply