Quantcast
Channel: Forum Microsoft Identity Manager
Viewing all articles
Browse latest Browse all 4767

ECMA 2.2 Full Import With AttributeType.Reference

$
0
0

Hi.

In my system i have a MA with GetSchema method

 Public Function GetSchema(configParameters As KeyedCollection(Of String, ConfigParameter)) As Schema Implements IMAExtensible2GetSchema.GetSchema
        ReadConfig(configParameters)

        Dim personType As Microsoft.MetadirectoryServices.SchemaType = Microsoft.MetadirectoryServices.SchemaType.Create(PersonObjectType, False)

        personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(PersonSchema.Personnummer, AttributeType.String))

...

personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute("AnsvarigChefRef", AttributeType.Reference))
        Dim sch As Schema = Schema.Create()
        sch.Types.Add(personType)
        Return sch

With "AnsvarigChefRef" attribute i want to save reference value of object maybe is Object Class or CSEntry I don't know >.<

So. In My GetImportEntries Method i try

Dim importReturnInfo As New GetImportEntriesResults
            Dim csentries As List(Of CSEntryChange) = New List(Of CSEntryChange)()

            Dim CountTemp As Integer = 0
            For i As Integer = CountPerson To CollectionPersonResult.Count - 1
                If CountTemp = _pageSize OrElse CountPerson >= CollectionPersonResult.Count Then
                    Exit For
                End If

                Logger.Create.GenerateInfoMessage(String.Format("Processing {0}/{1}", (i + 1).ToString(), CollectionPersonResult.Count.ToString()))


                Dim csentry As CSEntryChange = CSEntryChange.Create()
                csentry.ObjectModificationType = ObjectModificationType.Add
                csentry.ObjectType = PersonObjectType

Dim PersonInfo = CollectionPersonResult(i) //<== this is a collection of PersonInfo return from a service

....

                 

If PersonInfo.AnsvarigChef IsNot Nothing Then
                    csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(PersonSchema.AnsvarigChef, PersonInfo.AnsvarigChef))

Dim personRef = CollectionPersonResult.Where(Function(x) x.Personnummer = PersonInfo.AnsvarigChef).FirstOrDefault
                    If (personRef IsNot Nothing) Then
                        csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("AnsvarigChefRef", personRef))
                    End If
                End If

...

Error found here

"System.InvalidCastException: Unable to cast object of type 'ExternPersonInfo' to type 'System.String'.
   at Microsoft.MetadirectoryServices.Impl.Ecma2ConversionServices.AddAttributeToDImage(CDImage* pdimage, String attributeName, AttributeModificationType attributeModificationType, IList`1 attributeValueChanges, Int32 escapeReferenceDNValues)

with "ExternPersonInfo" is a Type of Service Return to my system

Please help me.

Thanks.


Viewing all articles
Browse latest Browse all 4767

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>