Condividi tramite


Create a set programmatically

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!

Comments

  • Anonymous
    February 12, 2009
    PingBack from http://www.clickandsolve.com/?p=7111

  • Anonymous
    February 13, 2009
    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.

  • Anonymous
    April 09, 2009
    I hadn't noticed the difference before.  Great observation!