Determine whether a password is set for ProtectionType.AllowOnlyFormFields

Hi,

I have to process documents with ProtectionType.AllowOnlyFormFields set.
I want to unprotect only these documents that don’t have an password set to unprotect, but I did not find a way to determine whether a password is set.
I tried with Unprotect(string password) method (on a clone) but it seems this returns false for a wrong password and true for null or empty string regardless if a password is set.

Any other options?

Best regards

@u.engelhardt Actually the password is not required to unprotect document protected with ProtectionType.AllowOnlyFormFields. So Document.Unprotect() method without specifying a password will unprotect the document. But Document.Unprotect(string) first checks whether the specified password is the password specified upon protection and then unprotects the document, if the password is wrong it returns false, as you mentioned.

Dear Alexey,

thank you very much for your answer.

But unfortunately, that doesn’t solve my problem.
In the code I don’t know whether the document is protected with a password or not, nor do I know the passwords of the protected documents. I am not allowed to unprotect password-protected documents with Document.Unprotect() and Document.Unprotect(string) behaves the same for password-protected documents and those without a password if I pass a wrong password or NULL or String.Empty.

I need to find out if document is protected (ProtectionType.AllowOnlyFormFields) without a password.

I tried:

docp.Unprotect(Guid.NewGuid().ToString())

Wrong password always returns false, even for documents without password.

docp.Unprotect(String.Empty) or docprotectPW.Unprotect(null)

Empty password or null always returns true, even for documents having a password (behaves like Document.Unprotect()).

Any other ideas?

Udo

@u.engelhardt
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-26170

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.