Service User Account Password Masked - Advanced Installer Community
prerak6962
Posts: 112
Joined: Mon Dec 08, 2014 5:26 pm

Service User Account Password Masked

Hello,

In my project, I have to create a service and assign an user account to it.
The user account is created before hand on the domain.

So, in order to achieve this, I add a new dialog in the installer which asks for the domain name, username and the password of the service user.
Now, in the "Services" page, I created a new service and for "Username" I could set the property [USER_DOMAIN]\[USER_NAME].

However, for the password, the field is masked. So, how can I assign the password property [USER_PASS] to the password?
Below is the screenshot of the same:
service_password.PNG
service_password.PNG (89.23 KiB) Viewed 32406 times
P.S: I am using Advanced Installer 16.1

Thank you.
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Service User Account Password Masked

Hello Prerak,

In order to achieve this, simply pass the property to it, as you have passed for the "Username" field (e.g. [USER_PASSWORD]).

Since the field is masked, all you have to do is to pay double attention to it so there will not be any mistakes in the spelling.

More information can be found in our "How to install a service for a custom user" article.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
prerak6962
Posts: 112
Joined: Mon Dec 08, 2014 5:26 pm

Re: Service User Account Password Masked

Hi Catalin,

Thank you for the response.
Your solution works perfectly fine.

However, it would be better to see the properties name instead of masked characters in order to avoid any typing mistakes.
It can be very difficult to find this mistake if there is one.
Maybe a property picker dialog can be added and it sets the selected property to avoid typing mistakes.

Also, in the article that you have provided the link to, this should be added that password field would be masked even when providing a property, to avoid the confusion.

Prerak
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Service User Account Password Masked

Hello Prerak,

You are always welcome.
However, it would be better to see the properties name instead of masked characters in order to avoid any typing mistakes.
Yes, I know that. However, we have made these changes to the visibility of the password field for security reasons.
Maybe a property picker dialog can be added and it sets the selected property to avoid typing mistakes.
This could actually do the trick. I will forward this suggestion to our development team and we will see what can be done about this. Thank you for your suggestion.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
prerak6962
Posts: 112
Joined: Mon Dec 08, 2014 5:26 pm

Re: Service User Account Password Masked

Hi Catalin,

Now there's one more issue that I am facing in my project.

During an update, I only have to update the files and nothing else.
As per my understanding, during an update process, the installer deletes the service -> uninstalls the old version -> installs the new version -> installs the service.

As I want to use the same user credentials for the service, I marked the properties "[USER_DOMAIN", "[USER_NAME]" and "[USER_PASS]" as persistent.
However in this case, the password is stored in plain text in the registry. This is a security issue and I can not have the password in plain text.
To tackle this, I marked "[USER_PASS]" as "Secure Property". This solves the plain text issue but now during the update the installer does not decrypt the password while setting the property and as a result the installer is stuck as "Starting Services" and fails after some time.

As the password does not match for the user, it is failing which is logical but I am not sure how to decrypt the password during the update.

I read a bit about SecureProp.dll which is included in the installer for secure properties and there's a function in it to decrypt the previously encrypted values. But as per this post: viewtopic.php?t=34233, I can not retrieve the return value of a dll function.

So, is there a way to make this work?

I hope I have made myself clear. If not, please let me know.

Thank you.
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Service User Account Password Masked

Hello Prerak,

Please have a look on the following thread:

viewtopic.php?f=2&t=7418#p102921

Please read it all (starting from the point I have given you) carefully as it is quite complicated to implement (hopefully my explanation is good enough, though).
:)

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
prerak6962
Posts: 112
Joined: Mon Dec 08, 2014 5:26 pm

Re: Service User Account Password Masked

Hi Catalin,

Thank you for the link.

I am trying to achieve the exact same thing as Collins in the other post.
If I understood it correctly, I'll need to write an external application (in C++ or Java or .NET) which would decrypt the password and store it in a public property of the installer.
Unfortunately for me, this is something that is out of the scope for the moment.
And personally I feel this is an overkill (unless I am missing something).

Is there any other way to do it?
If not, is there a way to store the password securely somewhere and reuse it during the update?

Thank you.
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Service User Account Password Masked

Hello Prerak,
If I understood it correctly, I'll need to write an external application (in C++ or Java or .NET) which would decrypt the password and store it in a public property of the installer.
No, that is not the case.

Please read the second page of threads as well.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
prerak6962
Posts: 112
Joined: Mon Dec 08, 2014 5:26 pm

Re: Service User Account Password Masked

Hi Catalin,

My bad. I did not realize there was a second page.

After reading it, it seems it should work.
So I integrated the custom actions provided in the last sample project on that thread.
The only thing that I added was "Upgrade" execution stage for those custom actions.

However, after these changes, my first installation is also failing. It says the service user does not have enough rights to launch the service.
If I uncheck the "Secure Property" for "[USER_PASSWORD]" it works completely fine.

So, could you please let me know when is the secure property encrypted?
Is it at run time as soon as the user types it? If yes, I think I'll need to decrypt it into other property and provide that in the password field for the service.

I'll try to create a sample project which might be able to reproduce the issue.

Thank you.
Prerak
prerak6962
Posts: 112
Joined: Mon Dec 08, 2014 5:26 pm

Re: Service User Account Password Masked

Hi Catalin,

After further investigation I was able to move a bit forward. Unable to find a solution though.

All this is happening during "First Install".

If I check the value of a secure property after the "Searhes" stage in "Install Execution Stage" it is same as what user entered (unencrypted).
However, if I check if just before "Install Services" stage it is encrypted. And as a result the installer fails at "Starting Services".

So, could you please let me know exactly in which stage the secure properties are encrypted?
And is it possible to move that stage after "StartServices" stage?

If not, I have a dirty workaround in my mind like:
- Assign secure property to a pubic property (non persistent) and set this public property in password field for the service
- During upgrade, decrypt the secure property and again set it to the public property which is used in password field for the service

This way, the service will always get the original value but the only downside is the public property would be visible in the logs.

So if there is a straight forward solution, it would be great. If not, I'll try the above workaround.
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Service User Account Password Masked

Hello Prerak,

First of all, please accept my apologies for the delayed reply.
My bad. I did not realize there was a second page.
That's fine, don't worry.
However, after these changes, my first installation is also failing. It says the service user does not have enough rights to launch the service.
If I uncheck the "Secure Property" for "[USER_PASSWORD]" it works completely fine.
Indeed, this happens due to the fact that the property is encrypted and can not be read. It does not have anything to do with elevated privileges.
So, could you please let me know when is the secure property encrypted?
Is it at run time as soon as the user types it? If yes, I think I'll need to decrypt it into other property and provide that in the password field for the service.
By default, the properties are encrypted during the deferred stage of the installation. As you could see, when you check the "Secure property" option for a property, a .dll is added to your project. During install, the calls to the .dll functions are done and the property is encrypted. Since it relies on the .dll to encrypt the property, it means that the encryption is done during the Deferred stage (when the .dll is copied on the target machine).
If I check the value of a secure property after the "Searhes" stage in "Install Execution Stage" it is same as what user entered (unencrypted).
However, if I check if just before "Install Services" stage it is encrypted. And as a result the installer fails at "Starting Services".
Please see my explanation above for this.
So, could you please let me know exactly in which stage the secure properties are encrypted?
To be more precise, this custom action runs right after the "Preparing" action group --> "InstallValidate" standard action. You can find this custom action by going to "Table Editor" page --> "InstallExecuteSequence" table --> "AI_SecureProperty" custom action.
And is it possible to move that stage after "StartServices" stage?
Yes, that is possible. By default, the "AI_SecureProperty" custom action has its sequence number equal to "1402", while the "StartService" action has its sequence number equal to "5850". With that being said, what we need here is to increase the sequence number of the "AI_SecureProperty" custom action to be > than 5850 (e.g. 5860). To do so, you can go to "Table Editor" --> "InstallExecuteSequence" --> find the "AI_SecureProperty" custom action and increase its sequence number.
If not, I have a dirty workaround in my mind like:
The first method should work just fine, so I do not think this will be necessary.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
prerak6962
Posts: 112
Joined: Mon Dec 08, 2014 5:26 pm

Re: Service User Account Password Masked

Hi Catalin,

Thank you for the answers. It certainly helped.

After setting "AI_SecureProperty" sequence value to 5860 I was able to successfully install the application.

How ever, the update was still failing as the installer was not able to decrypt the encrypted value.
Upon further investigation, I found that because of moving the sequence of "AI_SecureProperty" action, "WriteRegistryValues" action was executing first. As a result of this the password was set in plain text in registry and during upgrade it was trying to decrypt an uncrypted value and hence was failing.

To resolve this, I had to change the sequence of "WriteRegistryValues" action as well. I set it to 5861 in Table Editor and it worked like a charm.

Thank you very much for all the help :)

Prerak
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Service User Account Password Masked

You are always welcome, Prerak.

I am really glad you got this working.

Also, thank you for sharing your solution with us.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
prerak6962
Posts: 112
Joined: Mon Dec 08, 2014 5:26 pm

Re: Service User Account Password Masked

Hi Catalin,

I am encountering another issue now... :cry:
My service depends on the registry. It reads a few parameters from the registry on start.
But as I moved the "WriteRegistryValues" action after "StartServices" action, the service is not able to read the required registry values.

So, now if I move the "WriteRegistryValues" before "StartServices", the service won't start as the secure property gets encrypted during the registry writing.
It's a vicious cycle that I am stuck in now.

Do you any idea about how to get over this?

Thank you.
Prerak
prerak6962
Posts: 112
Joined: Mon Dec 08, 2014 5:26 pm

Re: Service User Account Password Masked

Hi Catalin,

Did you get a chance to have a look at the above mentioned issue?

Thanks.
Prerak

Return to “Common Problems”