Not able to Move the file from one site collection to another due to Sensitivity label

Copper Contributor

Hello Members,

 

I have developed a console application in C# to move the document from one site collection to another.

The code fails with message “Exception from HRESULT: 0x87FA0010” and ServerErrorTypeName as “System.UnauthorizedAccessException”. 

I tried to resolve the issue and came to know that this is happening because of sensitivity label assigned to SharePoint online site from where the code is trying to read the document that needs to be moved.

The site collection have sensitivity label "C2" attached to it. When I move the sensitivity label to "C1", the code was able the move the document to another site collection.

The reason seems to because of the fact that the code is not passing "Trusted Device" information while it is trying to move the document. Due to this SharePoint is considering the request is coming from a non-trusted device and not allowing the request to read the document.

 

I need to know how can I pass the "Trusted Device" information from my C# code.

Please help!

 

Reagrds,

Ratnesh

2 Replies

@ratnesh2927 Did you manage to find a solution?

Im having a similar issue where im trying to move a file from one document library to another with C#.

But my code is complaining on OpenBinaryStream. but still giving the exact same error as you mentioned.

@mattias123 @ratnesh2927 

Today Mattias and myself found the reason for this problem.

We had a conditional access policy in Azure which was causing such issue.

As soon as we excluded the related service account of our application from the policy 

CP312 [Sharepoint Online] - Require HAADJ or compliant device for SPO Service Accounts

the error was gone. We hope that helps others. Thanks a lot Mattias for beeing so patience.

Thx, Ronny