none
Microsoft.MetadirectoryServices.AttributeNotPresentException: Attribute "blah" is not present.

    Question

  • Hi,

    I am trying to write a custom extension in Visual Basic that creates Exchange mail-enabled users (MEUs) in my target directory, for each mailbox in my source directory. I have the code below in my source MA extension, and have specified "targetAddress" as the flow rule name under the advanced attribute flow on the source MA. However, when I run a sync on the source MA, it returns the error "Microsoft.MetadirectoryServices.AttributeNotPresentException: Attribute "targetAddress" is not present."

    Any idea what I could be doing wrong?

    Thanks in advance,

    Adam

     Case "targetAddress"
                    If csentry("targetAddress").IsPresent Then
                        mventry("targetAddress").Value = csentry("targetAddress").Value
                    Else
                        mventry("targetAddress").Value = ("SMTP:" & csentry("mailNickname").Value & "@contoso.com")
                    End If

    Wednesday, May 28, 2014 7:10 PM

Answers

All replies

  • Can you paste the whole exception?

    Thanks, Brian

    Wednesday, May 28, 2014 8:01 PM
    Moderator
  • Hi Brian,

    This is everything from the Call Stack Information:

    Microsoft.MetadirectoryServices.AttributeNotPresentException: Attribute "targetAddress" is not present.
       at Microsoft.MetadirectoryServices.Impl.AttributeImpl.get_Value()
       at Mms_Metaverse.MVExtensionObject.Provision(MVEntry mventry)

    Extension File Name: MVExtension.dll

    Extension Type: provisioning

    Thanks,

    Adam

    Wednesday, May 28, 2014 8:20 PM
  • So that's in your Provisioning code but you pasted a rules extension. Can you check your provisioning code?

    Thanks, Brian

    Wednesday, May 28, 2014 8:22 PM
    Moderator
  • Hmmm, interesting, so here is a portion of my provisioning code. I am using the ExchangeUtils.CreateMailEnabledUser method:

       dn = adMA.EscapeDNComponent("CN=" + mventry("cn").Value).Concat(container)
                    If 0 = adMA.Connectors.Count Then
                        If mventry("legacyExchangeDN").IsPresent Then
                            csentry = ExchangeUtils.CreateMailEnabledUser(adMA, dn, nickName, targetAddress)
                            csentry("proxyAddresses").Values.Add("SMTP:" & mventry("mail").Value)
                        Else
                            csentry = adMA.Connectors.StartNewConnector("user")
                            csentry.DN = dn
                            If mventry("mail").IsPresent Then
                            End If
                            csentry.CommitNewConnector()
                        End If

    Wednesday, May 28, 2014 8:29 PM
  • Where do you set the targetAddress variable?

    Thanks, Brian

    • Marked as answer by Adam Miceli Thursday, May 29, 2014 4:26 PM
    Wednesday, May 28, 2014 8:35 PM
    Moderator
  • It was up above from what I sent you, here:

    Public Sub Provision(ByVal mventry As MVEntry) _
        Implements IMVSynchronization.Provision

            Dim adMA As ConnectedMA
            Dim csentry As CSEntry
            Dim nickName, mailboxMDB, SMTPemail, targetAddress, container, stralias() As String
            Dim dn As ReferenceValue
            Dim sid As Byte()

            If mventry.ObjectType = "person" Then
                Try
                    adMA = mventry.ConnectedMAs("PRD")

                    nickName = mventry("uid").Value
                    targetAddress = mventry("targetAddress").Value
                    'mailboxMDB = mventry("info").Value
                    sid = mventry("objectSID").BinaryValue

    Wednesday, May 28, 2014 8:38 PM
  • Brian,

    Thanks for the tip. Even though you never responded to my last post, your question about where I was setting the targetAddress variable got me thinking. I changed the variable to the following, and things started to work!

    targetAddress = ("SMTP:" & mventry("mailNickname").Value & "@contoso.com")

    Adam

    Thursday, May 29, 2014 4:25 PM
  • Sorry I missed the last reply yesterday. Yes that will work - it will fail though if mailNickname is never null. You may want to do the IsPresent test and throw an UnexpectedDataException if you're missing mandatory attributes.

    Thanks, Brian

    Thursday, May 29, 2014 6:43 PM
    Moderator