I think this will depend on the version of Microsoft Word. Older versions of Word (prior to 2007) will require some COM interaction because they are not saved in open format. Nothing you can do to get around this, and I feel your disappointment that you are installing Office on a web server. In addition, I believe that the only way to detect password protection is to try to open / remove protection from the file and catch a certain exception (you may have to additionally evaluate the error code in this exception). Not beautiful!
However, for new versions of the word (2007+) saved in the open DOCX format ( Standard ECMA-376 ), you can examine the XML and check the existence of the DocumentProtection element with the w:enforcement attribute set to "on" ...
<w:DocumentProtection w:edit="read-only" w:enforcement="on" w:unprotectPassword="1FC6CBEB"/>
Note. The password recorded here is encrypted (obviously); I saved this particular document with the password "test".
Josh stodola
source share