i'm developing a plugin that should
1) un-protect the doent
2) do some action
3) protect the doent again

for example purpose, i've created an owner password protected doent
(let's say that the password is "12345")

using my plugin i'm able to do step 1 and 2, but on step 3 i fail.

here the code for 1)
AVDoc avDoc = AVAppGetActiveDoc();
PDDoc pdDoc = AVDocGetPDDoc(avDoc);
char pdfpass[1024];
strcpy(pdfpass, "12345");
if(PDDocPermRequest(pdDoc, PDPermReqObjDoc, PDPermReqOprSecure, NULL)
== 0) {
PDDocPermRequest(pdDoc, PDPermReqObjDoc, PDPermReqOprSecure,
StdSecurityDataRec* secData =
secData->perms = DocPrintHigh | DocPrintLow | PageModify;
PDDocPermRequest(pdDoc, PDPermReqObjDoc, PDPermReqOprPrintHigh,
PDDocPermRequest(pdDoc, PDPermReqObjPage, PDPermReqOprModify,

here the code for 2)
....simply some actions...

here the code for 3)
//update permissions
secData->perms = 0;
PDDocPermRequest(pdDoc, PDPermReqObjDoc, PDPermReqOprSecure, pdfpass);
PDDocSetNewSecurityData(pdDoc, secData);

.... and here comes problems.
Users can remove password security method in the security tab of the
properties windows for the doent, after they run my plugin.
Insted users should bleeing asked for insert the password in the
standard box, like it would be if they does not run the plugin and try
to change the security method of the doent.

Can anyone help me?