none
How is the info attribute not present? RRS feed

  • Question

  • I keep getting Microsoft.MetadirectoryServices.AttributeNotPresentException: Attribute "info" is not present.
       at Microsoft.MetadirectoryServices.Impl.AttributeImpl.get_Value()

    on my Advanced Attribute Import Flow. I have an AAIF for it, and have multiselected a few fields from the CSV to flow to it, so i can update the info attribute accordingly when there is a change. I know for a fact this code has worked to today. I tested changing an attribute and it update the info attribute accordingly. The info attribute has never existed in the CSV and it has worked before. Any ideas or things I can check?.   Here is a sample of the code.

    case "infoRule":
    if (mventry["firstName"].IsPresent)
    {

    if (mventry["firstName"].Value != csentry["FirstName"].Value

    || mventry["lastName"].Value != csentry["LastName"].Value)
    {

    mventry["info"].Value += TodaysDate + "-name changed from " + mventry["lastName"].Value + "," + mventry["firstName"].Value + " to " + csentry["LastName"].Value + "," + csentry["FirstName"].Value + "\r\n";
     }

     }

    Tuesday, July 3, 2012 3:34 PM

Answers

  • If nothing else, I'd suggest pulling all of those crazy if statements out into their own method so they're not cluttering up your case statement. It will be much cleaner and far more readable. e.g. something like this (note - this is off the top of my head, not compiled):

    switch(FlowRuleName)
    {
        case "infoRule":
            ProcessChanges(mventry, csentry);
            break;
    
        default:
            throw new EntryPointNotImplementedException(); 
    }
    
    
    private void ProcessChanges(MVEntry mventry, CSEntry csentry)
    {
        if (....)
        if (....) etc
    }

    I think Chris is likely onto something with appending a string to a value that may be null. An attribute won't be present in a metaverse object unless a management agent has previously contributed that attribute, so potentially there will be objects that don't have the info attribute present. I would probably make the first step in your process to check whether the info attribute is present, and if not, create a new one. Even if that isn't causing your problem, it's certainly good practice to do so (in the same way that you check for the presence of other attributes).

    • Marked as answer by mario.exe Monday, July 9, 2012 6:20 PM
    Tuesday, July 3, 2012 11:26 PM

All replies

  • looks like it has something to do with where my break; for my case statement, but how do you do the multiple attributes select on the import and have seperate case statements? When I try to map several attributes to info individually it complains there is already a mapping for it.  

    Tuesday, July 3, 2012 3:56 PM
  • Since this is an import rule, make sure that the "info" attribute is defined for the metaverse object type that the rule is flowing data in for.  If you have IAFs defined for more than object type, you may have it defined in Metaverse Designer for one but not the other.

    Based on your code, whether your CSV data source had a value for "info" or not seems irrelevant.

    If the problem is with your case statement, you'll need someone better at C# than me.  I usually work in VB.

    Chris


    p.s.  Also make sure this is in the import code section, and not the export method.
    Tuesday, July 3, 2012 8:41 PM
  • Thx for the reply, I am doing a person object and in our envirnment that is the only object in the MV that has the info attribute. It appears I just don't know what the protocol is in this situation in which I have different attributes that are flowed to the info attribute on an advanced import flow. I am doing something similar for the CN on the export. I have several different cases for the CN, because if the CN changes, it changes several attributes in our environment and that works with no problem.

    I don't know what the structure of the case statement should be or if I need to put the code somewhere else. It is now in the MapAttributesForImport section.

    Tuesday, July 3, 2012 8:55 PM
  • Is this CN being exported to a CSV file MA, or is this for Active Directory?  For AD you can only change the CN in the provisioning code as it is technically a move/rename of the object itself, not an attribute change.

    Taking another look at your case statement, it looks like you need a break; right after the code snippet if it isn't there in the real code.

    For more information about troubleshooting your code, see this article on how to attach the debugger to the process.

    Chris

    Tuesday, July 3, 2012 9:04 PM
  • The CN is being exported to AD, and that part is working great. I can do renames with no problem. There is indeed a break; in the statement but there is only one because I really don't know where to go from here. It appears that since I have so many if statements in the case statement, as soon as a condition applies the code complains the info attribute is not available, but if I comment all but one if statement it works rather or not the if statement's condition is met.  So I am fairly sure it is the structure of the case statement but not sure how to address the issue.   Here is a sample of all the code just in case it will give someone some ideas. i will give the debugger a try.

     void IMASynchronization.MapAttributesForImport(string FlowRuleName, CSEntry csentry, MVEntry mventry)
     {
     DateTime Today = DateTime.Now;
     string TodaysDate = Today.ToString();

     switch (FlowRuleName)
     {
     case "infoRule":
     if (mventry["firstName"].IsPresent)
     {

     if (mventry["firstName"].Value != csentry["FirstName"].Value || mventry["lastName"].Value != csentry["LastName"].Value)
     {
     mventry["info"].Value += TodaysDate + "-name changed from " + mventry["lastName"].Value + "," + mventry["firstName"].Value + " to " + csentry["LastName"].Value + "," + csentry["FirstName"].Value + "\r\n";
    }

    }

    if (mventry["classes"].IsPresent)
    {
    if (mventry["classes"].Value != csentry["classes"].Value)
    {
    mventry["info"].Value += TodaysDate + "-classes changed from " + mventry["classes"].Value + " to " + csentry["Classes"].Value + "\r\n"; 
    }
    }

    if (mventry["cn"].IsPresent)
    {
    if (mventry["cn"].Value != csentry["cn"].Value)
    {
    mventry["info"].Value += TodaysDate + "-username changed from " + mventry["cn"].Value + " to " + csentry["cn"].Value + "\r\n"; 

    }
    }

    if (mventry["physicalDeliveryOfficeName"].IsPresent)
    {
    if (mventry["physicalDeliveryOfficeName"].Value != csentry["CampusCode"].Value)
    {
    mventry["info"].Value += TodaysDate + "-Classes changed from " + mventry["classes"].Value + " to " + csentry["Classes"].Value + "\r\n"; 
    }
    }

    if (mventry["instructors"].IsPresent)
    {
     if (mventry["instructors"].Value != csentry["Instructors"].Value)
    {
    mventry["info"].Value += TodaysDate + "-instructors changed from " + mventry["instructors"].Value + " to " + csentry["Instructors"].Value + "\r\n";
    }
    }

    break;

    }
    }


    • Edited by mario.exe Tuesday, July 3, 2012 9:51 PM
    Tuesday, July 3, 2012 9:38 PM
  • I missed this before.  I think the problem could be the += when assigning the value to the mventry("info") attribute.  If the attribute does not have a value, the code probably can't append to it.

    Chris

    Tuesday, July 3, 2012 10:03 PM
  • If nothing else, I'd suggest pulling all of those crazy if statements out into their own method so they're not cluttering up your case statement. It will be much cleaner and far more readable. e.g. something like this (note - this is off the top of my head, not compiled):

    switch(FlowRuleName)
    {
        case "infoRule":
            ProcessChanges(mventry, csentry);
            break;
    
        default:
            throw new EntryPointNotImplementedException(); 
    }
    
    
    private void ProcessChanges(MVEntry mventry, CSEntry csentry)
    {
        if (....)
        if (....) etc
    }

    I think Chris is likely onto something with appending a string to a value that may be null. An attribute won't be present in a metaverse object unless a management agent has previously contributed that attribute, so potentially there will be objects that don't have the info attribute present. I would probably make the first step in your process to check whether the info attribute is present, and if not, create a new one. Even if that isn't causing your problem, it's certainly good practice to do so (in the same way that you check for the presence of other attributes).

    • Marked as answer by mario.exe Monday, July 9, 2012 6:20 PM
    Tuesday, July 3, 2012 11:26 PM
  • Chris, your suggestion about the += fixed the issue with it complaining about the the info attribute. Which is good. However I wanted to append to the info attribute, and if I take off the "+" it will overwrite the value with the last string that was set. So maybe I will have to use a stringbuilder object or something?? Nikki I hear you on the method suggestion, and I agree. I guess I will see if stringbuilder will append the attribute like I want. Thanks for all the suggestions!!!
    Tuesday, July 3, 2012 11:40 PM
  • Yep. Looks like I will have to use stringbuilder to append to the info attribute. Although, I don't fully understand why, since even if I was doing the += way to append, it should have only attempted to append to the info attribute if the attribute I was evaluating was present, and if the value of an attribute in the metaverse differed from the corresponding value of the attribute in the connectorspace??? Guess I will chalk it up to being a FIM thing??

    Wednesday, July 4, 2012 5:07 AM
  • if the value of an attribute in the metaverse differed from the corresponding value of the attribute in the connectorspace

    FIM can only know that the value is different after calculating it (based on the different connectorspace source attributes), that is why he executes the code, even if nothing changes in the destination metaverse attribute.

    If the metaverse attribute is not yet initialized, FIM will try to flow the desired value to it that is specified in the attribute flow. So even if the metaverse attribute "info" is empty, FIM will try to append to it (just as the code says it to do).
    • Edited by Wim Beck Wednesday, July 4, 2012 7:47 AM
    Wednesday, July 4, 2012 7:44 AM
  • That makes sense. Ok so is anyone using the info attribute or any mv attribute in this way on the import?

    Thursday, July 5, 2012 3:32 AM