Create a set programmatically

Published 12 February 09 12:30 PM

In answering a recent question, I provided an example of how to create a set programmatically.  Creating a set is no different than creating a group or person with one caveat.  A set requires a display name and a filter.  The display name is a simple string as expected, but the filter is a string that must contain a WS-Enumeration filter element.  Looking at schema alone you – and I – would assume to simply provide the XPath filter in the attribute value.  Instead you must wrap the XPath filter in the XML WS-Enumeration filter element.

Here is a working example from Release Candidate of ILM “2’ and the public client:

ResourceManagementObject rmObject = new ResourceManagementObject("Set");
rmObject["DisplayName"] = new ResourceManagementAttribute("DisplayName", "CreatedSet");
rmObject["Filter"] = new ResourceManagementAttribute("Filter", "<Filter xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" Dialect=\"http://schemas.microsoft.com/2006/11/XPathFilterDialect\" xmlns=\"http://schemas.xmlsoap.org/ws/2004/09/enumeration\">/Person</Filter>");
 
String newGroupId = transferClient.Create(rmObject);

Hope that helps!

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Create a set programmatically - Click &amp; Solve said on February 12, 2009 4:06 PM:

PingBack from http://www.clickandsolve.com/?p=7111

# Brad Turner said on February 13, 2009 9:59 AM:

Noticed that while tinkering with Sets and Search Scopes, and Search Scopes utilize the former assumption - they are not wrapped.  Looked to me like a "right hand/left hand" deal where the same attribute was implemented differently between two teams. My suggestion - lose the wrapper and make both objects use the same formatting to reduce confusion.

# JoeSchulman said on April 10, 2009 4:57 AM:

I hadn't noticed the difference before.  Great observation!

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

About JoeSchulman

I am a Program Manager working at Microsoft Corporation in Redmond, WA.

This Blog

Syndication

Page view tracker