Welcome! Log In Create A New Profile

Advanced

[WD23] How to define a password for an old file with no password?

Posted by Ola 
Ola
[WD23] How to define a password for an old file with no password?
November 16, 2020 11:12AM
Hi All

How to define a password for an old file with no password?
This is a HFSQL Classic file.
I created a new file without specifying any password for it
in order to make it easier to use WDMAP to see what's in
the file when testing it's maintenance form. Now it works
OK and I want to protect that file with a password.

So I defined the encryption parameters in the file description
and wrote the following code in my file opening process:

bRes is boolean
bRes = HChangePassword(FileName,gGloballyDefinedPassword)
IF OnTestMode THEN 
      Info("Test: bRes = " + bRes) //Displays 1 = True
END

HPass(FileName,gGloballyDefinedPassword)

IF not HCreationIfNotFound(FileName,gGloballyDefinedPassword) THEN 
      FileMessage("FileCreation","FileName")
END

I understand HChangePassword should be my friend, but it
isn't. It's a bully, steals my time.
It kinda seems to work, because it's result tested true after
using it, but the file still remains not-password-protected:
When I close the app and open the file with WDMAP,
it lets me in without asking for the password.
There seems to be some cognitive friction between me
and HChangePassword.

How can I make friends with HChangePassword?

Best regards
Ola



Edited 1 time(s). Last edit at 11/16/2020 11:13AM by Ola.
I had the problem a few years back and Fabrice helped me through it. If I remember correctly, he told me to:
1. change the settings of the file to include a password in the analysis
2. MAKE A CHANGE to the file structure (as I didn't need a change at that point he made me add a bDummy boolean field)


As a result, when the file was changed, the password was added. Again, if I remember correctly, I made a one time use code to change the password and then everything was fine.

The trick seems to be that you need to change the structure in order for the password to be added.
Re: [WD23] How to define a password for an old file with no password?
November 17, 2020 02:17PM
Hello Ola,

You should change the file in the security settings to password protected like Argus mentioned.

We use the following code in the init of the project:
IF NOT <File>..PasswordProtected THEN
IF HFileExist(<File>) THEN HChangePassword(<File>,<Password>)
END

You can make an array of strings and loop through the filenames.
Ola
Re: [WD23] How to define a password for an old file with no password?
November 17, 2020 03:39PM
Thanks Argus,

With this tip I managed to add a password to a file. Did several tests, though, and even managed to totally delete all the records in the file! This is a very delicate operation...
I'm still not friends with HChangePassword.

Best regards
Ola
Ola
Re: [WD23] How to define a password for an old file with no password?
November 17, 2020 04:18PM
Hi Koen,

Thank you. That's just what I was wondering, how to manage the passwording problem at customer site while upgrading the app.
I'll have to do some more testing.

Best regards
Ola
Ola
Re: [WD23] How to define a password for an old file with no password?
November 20, 2020 01:29PM
Hi all,

I did some further testing, and found out that if the password needs to be added to an old file,
HModifyStructure must be used to modify the file. WDModfic.exe is not able to handle a new password when modifying a file. WDModfic.exe does nothing, if a password is given to it: no change in structure, no password applied, app fails when started.

I would suppose that the same applies if the password needs to be changed.
Now I've got this covered.

Thanks for the help.
[www.youtube.com]

Best regards
Ola
P.S. I wouldn't have minded, if the online help would have had a few words about this.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: