Resources for IT Professionals > Forums Home > Identity Management Forums > Identity Lifecycle Manager 2 > Improvements and bug fixes in the FIM RC1 Web Service client.
Ask a questionAsk a question
 

General DiscussionImprovements and bug fixes in the FIM RC1 Web Service client.

All Replies

  • Monday, October 19, 2009 2:46 PMPaolo Tedesco Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Enumeration responses do not include the total number of matching objects

    When you run an Enumerate request, the response does not get the total count of objects that matched the query filter, which is an important piece of information if the total number of results is higher than the limit on the number of returned objects.

    To add this missing feature, you must add an EnumerationDetail class as follows:

        [XmlRoot]
        public class EnumerationDetail {
            [XmlElement()]
            public int Count;
        }
     
    Then you need to modify the EnumerateResponse class to add that element (file EnumerationResponse.cs). Here I'm also adding a "convenience" property that will store the total number of results:

        [XmlRoot(Namespace = Constants.WsEnumeration.Namespace)]
        public class EnumerateResponse : PullResponse {

            [XmlElement(Namespace = Constants.Rm.Namespace)]
            public EnumerationDetail EnumerationDetail;

            [XmlIgnore()]
            public int? Count {
                get {
                    if (null == EnumerationDetail) {
                        return null;
                    } else {
                        return EnumerationDetail.Count;
                    }
                }
            }
        }

    And finally you have to go to the WsEnumerationClient.cs file and add a message header to request for the count information (add the lines in bold to the Enumerate method inside the lock block):

            public EnumerateResponse Enumerate(EnumerationRequest request) {
                // code omitted for brevity ...
                lock (request) {
                    enumerateRequest = Message.CreateMessage(MessageVersion.Default, Constants.WsEnumeration.EnumerateAction, request, new ClientSerializer(typeof(EnumerationRequest)));
                    MessageHeader includeCount = MessageHeader.CreateHeader("IncludeCount",Constants.Rm.Namespace,null);
                    enumerateRequest.Headers.Add(includeCount);
                }
                // code omitted for brevity ...
            }


    Paolo Tedesco - http://espace.cern.ch/idm
  • Monday, October 19, 2009 2:51 PMPaolo Tedesco Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Comparing RmReference objects with a null reference as a left-side operator causes a NullReferenceException

    If you compare an RmReference object against a null reference on the left side of the comparison operator, you get a NullReferenceException, e.g:

                RmReference a = SomeOperation();
                if (null != a) { // crashes

    You can fix this by re-defining the == and != operators of the RmReference class as follows:

            public static bool operator ==(RmReference attrib1, RmReference attrib2) {
                if (attrib1 as object == null)
                    return (attrib2 as object == null);
                if (attrib2 as object == null)
                    return false;
                return attrib1.CompareTo(attrib2) == 0;
            }

            public static bool operator !=(RmReference attrib1, RmReference attrib2) {
                if (attrib1 as object == null)
                    return (attrib2 as object != null);
                if (attrib2 as object == null)
                    return true;
                return attrib1.CompareTo(attrib2) != 0;
            }


    Paolo Tedesco - http://espace.cern.ch/idm
  • Tuesday, October 20, 2009 4:52 PMJoe SchulmanMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Love it!

  • Friday, October 23, 2009 11:37 AMPaolo Tedesco Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code

    IsMultiValue property of RmAttributeValue class returns true whenever the attribute has a value

    RmAttributeValue stores values internally as a list, and IsMultiValue property is defined as

        public bool IsMultiValue {
            get {
                return this.isMultiValue || this.values.Count > 0;
            }
        }
    

    Thus it returns true when at least one value is stored. The property should be defined as

        public bool IsMultiValue {
            get {
                return this.isMultiValue || this.values.Count > 1;
            }
        }
    

    Paolo Tedesco - http://espace.cern.ch/idm
  • Monday, October 26, 2009 5:08 PMPaolo Tedesco Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    CopyTo method of RmList makes a copy the wrong way round

    The CopyTo method in RmList is defined as follows:

        public void CopyTo(T[] array, int arrayIndex) {
            int j = arrayIndex;
            for (int i = 0; i < array.Length; i++) {
                this.values[j] = this.ConvertTo(array[i]);
                j++;
            }
        }
    

    This actually is copying the array into the list, while it should be the opposite. If you try to initialize a List with the contents of an RmList the code will crash.

    I think that the correct implementation of the method should be like this:

        public void CopyTo(T[] array, int arrayIndex) {
            for (int i = 0; i < this.values.Count; i++) {
                array[i + arrayIndex] = this.ConvertFrom(this.values[i]);
            }
        }
    


    Paolo Tedesco - http://espace.cern.ch/idm