none
VB MA extension code to write back single proxyAddresses value to source AD RRS feed

  • Question

  • Hi,

    I am trying to modify some extension code for a management agent that will do the following:

    If a user object in my "target" Active Directory connected data source has a proxyAddresses value that contains a certain sting of characters (i.e. "/o=ExchangeLabs/"), then I want to take only that proxyAddresses value, and write it back to that same user object in my "source" Active Directory connected data source.

    Normally, I am flowing all proxyAddresses from the source AD to the target AD, but there may be this one proxyAddress in the target that I want to flow back to the source. It would be just this one value, and I want to write it back without affecting any of the other values that are already there. I would prefer that that code be in VB, if possible.

    Thanks in advance,
    Adam

    Monday, June 9, 2014 5:36 PM

Answers

  • Hello Adam,

    I am assuming you want to create an advanced flow in the sync engine. In order to do this you will need to enumerate the list of values in the multivalued attribute and look for the one you need. This is pretty straight forward.

        ' Create a temp object to use for enum
        Dim placeHolder As Value
    
        ' Create an empty string value collection.
        Dim newListOfAddress As ValueCollection
    
        ' Clear my new collection
        newListOfAddress.Clear()
    
        For Each placeHolder In csentry("proxyAddressess").Values
            If Not mailElement.ToString.ToLower.StartsWith("smtp:") Then
                '' TODO - Do something with the value
            Else
                '' TOTO - Do nothing and look at the next one
            End If
        Next
    
        ' Now you have a value collection you can put in the MV to flow out to another AD (or something)
        mventry("myNewList").Values = newListOfAddress
    

    Hope this helps


    Almero Steyn (http://www.puttyq.com) [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or "Helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster.]

    Thursday, June 12, 2014 6:51 AM
  • Almero's sample would clear out the existing proxies in the source. Something like this would work. You'd want to have a metaverse attribute called targetSystemProxyAddresses (or something to that effect) with a import flow rule to populate it.

        ' Create an empty string value collection.
        Dim newListOfAddress As ValueCollection
    
        ' Clear my new collection
        newListOfAddress = csentry("proxyAddresses").Values
    
        For Each item as Value In mventry("targetSystemProxyAddresses").Values
            If Not item.ToString() = "Something" Then
                newListOfAddress.Add(item)
            End If
        Next
    
    csentry("proxyAddresses").Values = newListOfAddress


    Thanks, Brian

    Thursday, June 12, 2014 3:43 PM
    Moderator
  • Adam-

    The sample I posted was for export. You can't write to the CSEntry on import - you'd need the reverse the flow slightly so you're writing to the MVEntry if that's what you're trying to do.


    Thanks, Brian

    • Marked as answer by am12375 Monday, June 23, 2014 9:29 PM
    Monday, June 23, 2014 8:29 PM
    Moderator

All replies

  • Hello Adam,

    I am assuming you want to create an advanced flow in the sync engine. In order to do this you will need to enumerate the list of values in the multivalued attribute and look for the one you need. This is pretty straight forward.

        ' Create a temp object to use for enum
        Dim placeHolder As Value
    
        ' Create an empty string value collection.
        Dim newListOfAddress As ValueCollection
    
        ' Clear my new collection
        newListOfAddress.Clear()
    
        For Each placeHolder In csentry("proxyAddressess").Values
            If Not mailElement.ToString.ToLower.StartsWith("smtp:") Then
                '' TODO - Do something with the value
            Else
                '' TOTO - Do nothing and look at the next one
            End If
        Next
    
        ' Now you have a value collection you can put in the MV to flow out to another AD (or something)
        mventry("myNewList").Values = newListOfAddress
    

    Hope this helps


    Almero Steyn (http://www.puttyq.com) [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or "Helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster.]

    Thursday, June 12, 2014 6:51 AM
  • Almero's sample would clear out the existing proxies in the source. Something like this would work. You'd want to have a metaverse attribute called targetSystemProxyAddresses (or something to that effect) with a import flow rule to populate it.

        ' Create an empty string value collection.
        Dim newListOfAddress As ValueCollection
    
        ' Clear my new collection
        newListOfAddress = csentry("proxyAddresses").Values
    
        For Each item as Value In mventry("targetSystemProxyAddresses").Values
            If Not item.ToString() = "Something" Then
                newListOfAddress.Add(item)
            End If
        Next
    
    csentry("proxyAddresses").Values = newListOfAddress


    Thanks, Brian

    Thursday, June 12, 2014 3:43 PM
    Moderator
  • Brian, is your proposed answer meant to compliment Almero's suggestion, or as an alternative? I am trying to implement this. I added your code into the MapAttributesForImport section of my target MA extension, then configured an advanced import flow rule on the target MA to flow proxyAddresses to targetSystemProxyAddresses. However, when I run a sync, I get an extension error with the following:

    Extension Type: import-flow

    Extension Context: targetSystemProxyAddresses

    Call Stack Information:

    System.InvalidOperationException: attribute proxyAddresses is read-only
       at Microsoft.MetadirectoryServices.Impl.GenericValueCollection.AddValueWorker(Object newValue)
       at Mms_ManagementAgent_USiMAExtension.MAExtensionObject.MapAttributesForImport(String FlowRuleName, CSEntry csentry, MVEntry mventry)

    Monday, June 23, 2014 7:43 PM
  • I should also clarify that I do not want to clear out the existing proxies in the source. I only want to append this one value to whatever is already there.

    Thanks.

    Monday, June 23, 2014 8:13 PM
  • Adam-

    The sample I posted was for export. You can't write to the CSEntry on import - you'd need the reverse the flow slightly so you're writing to the MVEntry if that's what you're trying to do.


    Thanks, Brian

    • Marked as answer by am12375 Monday, June 23, 2014 9:29 PM
    Monday, June 23, 2014 8:29 PM
    Moderator
  • OK, I got it working now. Thanks for pointing me in the right direction, Brian!
    Monday, June 23, 2014 9:29 PM