none
Uniqueness check against the Metaverse RRS feed

  • Question

  • Hi

    I want to check uniqueness check against the Metaverse so i create one Management agent Rule Extension in fim synchronization service manager first i mapped UID User(Active Directory) with metaverse atrribute PERSON (UID ) advance mapping with import and export and write some code in management agent.after doing this we build the project succesfully and .dll file also put in Extension folder.but problem is that UID attribute is not flowing in connector space when we run the full import of ADMA agent so please suggest me where i am wrong.for help we given the code which i wrote

     Const DB_CONNECTION_STRING As String = "Database=FIMSynchronizationService;Data Source=localhost;Integrated Security=TRUE;"

    Public Sub MapAttributesForImport(ByVal FlowRuleName As String, ByVal csentry As CSEntry, ByVal mventry As MVEntry) Implements IMASynchronization.MapAttributesForImport
            ' TODO: write your import attribute flow code
            'Throw New EntryPointNotImplementedException()
            Select Case FlowRuleName

    Case "import_uid"
                    Dim uid As String = ""
                    Dim index As Integer
                    Dim sqlQueryConnection As New SqlConnection(DB_CONNECTION_STRING)
                    Dim rowReader As SqlDataReader
                    Dim unique As Boolean = False
                    If csentry("firstName").IsPresent AndAlso csentry("lastName").IsPresent Then
                        uid = csentry("firstName").Value.Chars(0) & csentry("lastName").Value
                        index = 1
                        Do Until unique Or index > 99
                            Dim query As String = "select count (*) from mms_metaverse with (NOLOCK) " _
                                                & "where object_type = 'person' and uid = '" & uid & "'"
                            Dim sqlQuery As New SqlCommand(query, sqlQueryConnection)
                            sqlQueryConnection.Open()
                            rowReader = sqlQuery.ExecuteReader
                            rowReader.Read()
                            If rowReader.GetInt32(0) > 0 Then
                                If index > 1 Then
                                    uid = uid.Replace((index - 1).ToString, "")
                                End If
                                uid = uid & index.ToString
                            Else
                                unique = True
                            End If
                            index = index + 1
                            sqlQueryConnection.Close()
                        Loop
                        If index < 100 And uid <> "" Then
                            mventry("uid").Value = uid
                        End If
                    End If

         Case Else
                    ' TODO: remove the following statement and add your default script here
                    Throw New UnexpectedDataException("Unexpected Export flow rule name:" & FlowRuleName)

     

            End Select
        End Sub

     

    Public Sub MapAttributesForExport(ByVal FlowRuleName As String, ByVal mventry As MVEntry, ByVal csentry As CSEntry) Implements IMASynchronization.MapAttributesForExport
            ' TODO: Add export attribute flow code here
            Select Case FlowRuleName

      Case "export_uid"
                    ' TODO: remove the following statement and add your scripted export attribute flow here
                    If mventry("uid").IsPresent Then

                        csentry("uid").Value = mventry("uid").Value
                    Else
                        Throw New UnexpectedDataException("uid missing")

                    End If

     Case Else
                    ' TODO: remove the following statement and add your default script here
                    Throw New UnexpectedDataException("Unexpected Export flow rule name:" & FlowRuleName)

     

            End Select
        End Sub

    Regards

    Anil Kumar



    Wednesday, June 20, 2012 6:29 AM

Answers

  • I think that the approach to query DB directly is wrong - if You want to check something against metaverse use FindMVEntries from API

    http://msdn.microsoft.com/en-us/library/windows/desktop/ms698819(v=vs.85).aspx

    Wednesday, June 20, 2012 9:26 AM
  • What is the behavior you see? Does it throw an error, flow in duplicate values, or is it not deleting values when you expect it to?

    Remember that when you run an import, the IAF rules are not evaluated.  That happens when you run a synchronization.  The two processes can be combined in a single run profile step, put into two separate steps of a run profile, or could even be separated into two different run profiles.

    Also keep in mind that if the mailAttribute value is the only source attribute on the data source side of your import rule, the code will not be called if the attribute is not present in the connector space.  In order to ensure that the code is run for an empty attribute, a second attribute that is always present (think about your anchor value) must be included as a source for the sync engine to evaluate the rule.  Your code doesn't actually have to make use of the second attribute.

    Chris

    Wednesday, June 20, 2012 2:47 PM

All replies

  • I think that the approach to query DB directly is wrong - if You want to check something against metaverse use FindMVEntries from API

    http://msdn.microsoft.com/en-us/library/windows/desktop/ms698819(v=vs.85).aspx

    Wednesday, June 20, 2012 9:26 AM
  • Hi Tomasz,

    Thank's for reply

    I have been also implement below code but attribute is not flow in connector space when we run full import of ADMA agent so please tell me how to create or check Uniqueness check against the Metaverse.  

    Public Sub MapAttributesForImport( _
        ByVal FlowRuleName As String, _
        ByVal csentry As CSEntry, _
        ByVal mventry As MVEntry) _
        Implements IMASynchronization.MapAttributesForImport

        Select Case FlowRuleName
            Case "mailNicknameMapping"
                ' If the mailnickname attribute exists, set to attribute to
                ' a value from the nickname function. If the nickname attribute
                ' does not exist, delete the metaverse entry.
                If csentry("mailnickname").IsPresent Then
                    ' The value for the mailnickname attribute should be unique on every
                    ' metaverse entry. To create a unique value, call a function that
                    ' calculates a unique name based upon the connector space entry.
                    ' Use this calculated value as the attribute value for the metaverse
                    ' entry.
                    Dim newMailNickname As String
                    newMailNickname = GetCheckedMailNickName(csentry("mailnickname").Value, mventry)

                    ' If a unique nickname could not be created, throw an exception.
                    If newMailNickname.Equals("") Then
                        Throw New TerminateRunException("A unique mailNickname could not be found")
                    End If

                    mventry("mailNickname").Value = newMailNickname
                Else
                    mventry("mailNickname").Delete()
                End If
            Case Else
        End Select
    End Sub

    ' This function checks passed value for uniqueness and also creates new values.
    Public Function GetCheckedMailNickName( _
          ByVal mailNickname As String, _
          ByVal mventry As MVEntry) As String

        Dim findResultList() As MVEntry
        Dim checkedMailNickname As String = mailNickname
        GetCheckedMailNickName = ""

        Dim nameSuffix As Integer
        Dim mvEntryFound As MVEntry

        ' Create a unique naming attribute by adding a number to
        ' the existing mailNickname value.
        For nameSuffix = 1 To 100
            ' Check if the passed mailNickname value exists in the metaverse by
            ' using the Utils.FindMVEntries method.
            findResultList = Utils.FindMVEntries("mailNickname", checkedMailNickname, 1)

            ' If the value does not exist in the metaverse, use the passed value
            ' as the metaverse value.
            If findResultList.Length = 0 Then
                GetCheckedMailNickName = checkedMailNickname
                Exit For
            End If

            ' Check that the connector space entry is connected to the
            ' metaverse entry.
            mvEntryFound = findResultList(0)
            If mvEntryFound Is mventry Then
                GetCheckedMailNickName = checkedMailNickname
                Exit For
            End If

            ' If the passed value already exists, concatenate the counter number
            ' to the passed value and verify this new value exists. Repeat
            ' this step until a unique value is created.
            checkedMailNickname = mailNickname & nameSuffix.ToString
        Next
    End Function

    Regards

    Anil Kumar

    Wednesday, June 20, 2012 12:36 PM
  • What is the behavior you see? Does it throw an error, flow in duplicate values, or is it not deleting values when you expect it to?

    Remember that when you run an import, the IAF rules are not evaluated.  That happens when you run a synchronization.  The two processes can be combined in a single run profile step, put into two separate steps of a run profile, or could even be separated into two different run profiles.

    Also keep in mind that if the mailAttribute value is the only source attribute on the data source side of your import rule, the code will not be called if the attribute is not present in the connector space.  In order to ensure that the code is run for an empty attribute, a second attribute that is always present (think about your anchor value) must be included as a source for the sync engine to evaluate the rule.  Your code doesn't actually have to make use of the second attribute.

    Chris

    Wednesday, June 20, 2012 2:47 PM
Internal Server Error
Internal Server Error

Sorry, We were unable to service your request. Please try again later.

For the latest headlines and see what's new, visit the TechNet home page.

Check out the various Tech Centers where you can find the latest product information, technical resources and community offerings.

Visit the TechNet Library for the latest technical articles, reference documentation, downloads and more.

Browse to TechNet Forums to get fast answers for technical questions or use the search option below to find out other relevant resources.