locked
Export rules extension flow code RRS feed

  • Question

  • This is going to seem very basic, but what I am trying to accomplish is to bring the nickName field into Active Directory unless that attribute is empty.  If it's empty then I want the givenName.  The following code did not work. Nothing was brought into the givenName.  Perhaps my understand of what "isPresent" is not correct?

                        if (mventry["nickName"].IsPresent)
                        {
                            csentry["givenName"].Value = mventry["nickName"].Value;
                        }
                        else if (mventry["givenName"].IsPresent)
                        {
                            csentry["givenName"].Value = mventry["givenName"].Value;
                        }
                        else
                        {
                            csentry["givenName"].Value = null;
                        }


    I am thinking that, in addition to checking to see if nickName is Present, I also need to see if it contains a value.  Does the following seem more likely to work?

                        if (mventry["nickName"].IsPresent && !mventry["nickName"].Value.Equals(""))
                        {
                            csentry["givenName"].Value = mventry["nickName"].Value;
                        }
                        else
                        {
                            csentry["givenName"].Value = mventry["givenName"].Value;
                        }
    Tuesday, June 23, 2009 2:30 PM

Answers

  • (mventry["nickName"].IsPresent) becomes true when the MV object has a attribute "nickName". It does not care if the attribute has a value, NullValue or whatever else.
    • Marked as answer by ccbcmike Wednesday, June 24, 2009 11:57 AM
    Wednesday, June 24, 2009 6:36 AM

All replies

  • Your code seems to be fine to me...
    Did you try to debug in Visual Studio and see how the condition evaluates?
    Tuesday, June 23, 2009 2:42 PM
  • I haven't tried it in Debug mode.

    But what I need to know is, by using

                      if (mventry["nickName"].IsPresent)

    will that only be true when nickName contains a value that's not null ?
    Tuesday, June 23, 2009 11:09 PM
  • (mventry["nickName"].IsPresent) becomes true when the MV object has a attribute "nickName". It does not care if the attribute has a value, NullValue or whatever else.
    • Marked as answer by ccbcmike Wednesday, June 24, 2009 11:57 AM
    Wednesday, June 24, 2009 6:36 AM
  • Thanks!  That's what I needed to know.  And that explains why my first code didn't work.  I'll proceed using my second code example that I listed.
    Wednesday, June 24, 2009 11:57 AM
  • Definitely watch out for empty string values, they will change your code a bit, you might still want to check a value and is a good way to code in general... Always try to think out of the box...

    When an attribute is populated in the metaverse, ispresent will pass true.
    When an attribute is not on the object in the metverse, ispresent will pass false.

    You have to becareful sometimes with advanced flows, because if you are looking at an attribute that doesn't have a value as a source, it won't be kicked off unless you have another attribute selected in the source.

    Just something to look out for...

    Joe


    Joe Stepongzi - Identity Management Consultant - ILM MVP - www.microsoftIdM.com,ilmXframework.codeplex.com
    Friday, July 3, 2009 9:14 PM