Sample Scenario: Get a specific person with extensions

Today’s sample code at first glance may seem like a basic copy-paste of our last post.  In many ways it is.  We show you today how to get a specific person like last time, but this time we specify which attributes to retrieve.  In the previous example we let the ILM Service return all available attributes.  For larger objects or objects with very large attributes, the extra data flowing across the wire may slow down your client code.  For this reason we added the Transfer Extensions for Identity Management Operations to the WS-Transfer protocol, and recall that we described these extensions in Topic 7.

The client works hard to abstract away using TEIMO and not using TEIMO.  The only difference in client calls is specifying the set of attributes to retrieve.  Specifying this list means using TEIMO, and omitting this list means using regular WS-Transfer.  If an attribute you ask for does not exist on the object or you do not have permission to read it, the whole web service call will result in a PermissionDenied SOAP Fault.

Let’s look at the code:

        static void Topic12GetPersonExtensions()

        {

            WSTransferClient transferClient = new WSTransferClient();

            transferClient.ClientCredentials = GetCredentials();

            String objectId = GetPersonId;

            String[] attribs = new String[]{

                "DisplayName",

                "FirstName",

                "LastName",

            };

            ResourceManagementObject person = transferClient.Get(objectId, attribs);

            Assert.IsTrue(objectId.Equals(person.ObjectId));

            Console.WriteLine("Topic 12 Complete");

        }

As you can see, this code looks very similar to the code posted in the previous example. The only difference is here we provide a string array of attribute names, attribs , in addition to the ObjectID.

That’s it!  If you are curious to see how the client constructs the SOAP messages, I encourage you to open up Visual Studio and step through the code.  Be sure to add watches for the request and response messages in the client to see exactly what data is sent across the wire.

In our next post we will discuss how to get person objects when you don’t know the ObjectID.  This technique is useful for searching for objects and uses WS-Enumeration.