Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with Serialization/Arrays Value #15

Open
sfonteneau opened this issue Dec 8, 2022 · 3 comments
Open

problem with Serialization/Arrays Value #15

sfonteneau opened this issue Dec 8, 2022 · 3 comments

Comments

@sfonteneau
Copy link

I use your project to communicate with Microsoft servers, it works fine except when using Serialization/Arrays :

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
        <s:Header>
            <a:Action s:mustUnderstand="1">http://schemas.microsoft.com/online/aws/change/2010/01/IProvisioningWebService/ProvisionAzureADSyncObjects</a:Action>
            <SyncToken s:role="urn:microsoft.online.administrativeservice" xmlns="urn:microsoft.online.administrativeservice" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <ApplicationId xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">1651564e-7ce4-4d99-88be-0a65050d8dc3</ApplicationId>
                <BearerToken xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">token</BearerToken>
                <ClientVersion xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">8.0</ClientVersion>
                <DirSyncBuildNumber xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">1.5.29.0</DirSyncBuildNumber>
                <FIMBuildNumber xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">1.5.29.0</FIMBuildNumber>
                <IsInstalledOnDC xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">False</IsInstalledOnDC>
                <IssueDateTime xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">0001-01-01T00:00:00</IssueDateTime>
                <LanguageId xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">en-US</LanguageId>
                <LiveToken xmlns="http://schemas.microsoft.com/online/aws/change/2010/01"/>
                <ProtocolVersion xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">2.0</ProtocolVersion>
                <RichCoexistenceEnabled xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">False</RichCoexistenceEnabled>
                <TrackingId xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">da890d67-152c-498a-8272-a4b5fbf1c023</TrackingId>
            </SyncToken>
            <a:MessageID>urn:uuid:da890d67-152c-498a-8272-a4b5fbf1c023</a:MessageID>
            <a:ReplyTo>
                <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
            </a:ReplyTo>
            <a:To s:mustUnderstand="1">https://adminwebservice.microsoftonline.com/provisioningservice.svc</a:To>
        </s:Header>
        <s:Body>
            <ProvisionAzureADSyncObjects xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">
                <syncRequest xmlns:b="http://schemas.microsoft.com/online/aws/change/2014/06" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                    <b:SyncObjects>
                        <b:AzureADSyncObject>
                            <b:PropertyValues xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                                <c:KeyValueOfstringanyType><c:Key>SourceAnchor</c:Key><c:Value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">test</c:Value></c:KeyValueOfstringanyType>
                                <c:KeyValueOfstringanyType><c:Key>displayName</c:Key><c:Value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">testsf41</c:Value></c:KeyValueOfstringanyType>
                                <c:KeyValueOfstringanyType><c:Key>userPrincipalName</c:Key><c:Value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">[email protected]</c:Value></c:KeyValueOfstringanyType>
                            </b:PropertyValues>
                            <b:SyncObjectType>User</b:SyncObjectType>
                            <b:SyncOperation>Set</b:SyncOperation>
                        </b:AzureADSyncObject>
                    </b:SyncObjects>
                </syncRequest>
            </ProvisionAzureADSyncObjects>
        </s:Body>
 </s:Envelope>

Answer :

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/online/aws/change/2010/01:syncRequest. The InnerException message was 'Element 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:Value' contains data from a type that maps to the name ':mustUnderstand'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver if you are using DataContractSerializer or add the type corresponding to 'mustUnderstand' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to the serializer.'.  Please see InnerException for more details.

I tried to look but I admit that I did not find

the project :

https://github.com/sfonteneau/AADInternals_python

@bluec0re
Copy link
Contributor

bluec0re commented Jan 5, 2023

Haven't worked with Microsoft environments for years... Can you confirm that it works with the powershell scripts your project is based on? (just to confirm that it's not a server side issue).

And if so, can you share the binary representation sent by the powershell scripts, so that I can compare?

@AndreasLrx
Copy link

After debugging the library with @sfonteneau I found out two issues:

  • QNameDictionaryTextRecord encoding
  • Float/Version detection

The first one is fixed in #16

For the float detection we have this element:

<ClientVersion xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">8.0</ClientVersion>

The text "8.0" is encoded as a DoubleTextRecord but it is a version in this context, and Microsoft servers are expecting a string not a float.
Any idea how to specify if the string is a version ? (It is not blocking for us, we can fork and comment out the float regex match in parse_data)

@AndreasLrx
Copy link

For the record, I compared with the powershell xml to binary output and powershell use char encoding almost everywhere:

  • There is no usage of the known types (from dictionnary.py), instead each types are written in string
  • The '8.0' is encoded as a Char Text Record
  • The uuid and bytes are not detected (and encoded as Char Text too)

sfonteneau added a commit to sfonteneau/python-wcfbin that referenced this issue Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants