Windows Service User Account Credentials
-
hi folks, I have been working on a windows service application which monitors a specific mailbox on an exchange server. The application works as intended with one exception. The exception being the storage of the username and password that will be accessing the mailbox. Currently, as a crude method to test my application, I stored the username and password in an encrypted format in an xml file. I had the idea that the user account I specified to run the windows service application can be used to access the mailbox provided the user has been granted access via Active Directory (which I have taken care off). By doing this allows me to ensure that the user account is in sync with AD. The problem is at runtime how do I get the username and password of the account specified to run the windows service application to access the mailbox. I tried the Service Installer Process which has Properties to GET/SET the user name and password but this is only for install time not run time. Any ideas as to how I can tackle this ? Or maybe what is the best practice way of doing this? thanks V
-
hi folks, I have been working on a windows service application which monitors a specific mailbox on an exchange server. The application works as intended with one exception. The exception being the storage of the username and password that will be accessing the mailbox. Currently, as a crude method to test my application, I stored the username and password in an encrypted format in an xml file. I had the idea that the user account I specified to run the windows service application can be used to access the mailbox provided the user has been granted access via Active Directory (which I have taken care off). By doing this allows me to ensure that the user account is in sync with AD. The problem is at runtime how do I get the username and password of the account specified to run the windows service application to access the mailbox. I tried the Service Installer Process which has Properties to GET/SET the user name and password but this is only for install time not run time. Any ideas as to how I can tackle this ? Or maybe what is the best practice way of doing this? thanks V
The question seems strange, normally, you set the account when you install the service and this account runs the service, thus accesses the mailbox. So there is no reason to put it in the code. You can look at this by looking at the properties of any other service. Usually they run as System or other services, and if you are an administrator of the domain you do not have to enter any password. Make sure that either the server machine or the Domain Controllers group has access to the mailbox.
-
The question seems strange, normally, you set the account when you install the service and this account runs the service, thus accesses the mailbox. So there is no reason to put it in the code. You can look at this by looking at the properties of any other service. Usually they run as System or other services, and if you are an administrator of the domain you do not have to enter any password. Make sure that either the server machine or the Domain Controllers group has access to the mailbox.
thanks for the response. Well I was not clear when I had initially explained, the code I am using to access the mailbox, you need to explicitly provide the username and password. Hence my original question, how does one extract the username and password of the User Account which is running the service applications.
-
thanks for the response. Well I was not clear when I had initially explained, the code I am using to access the mailbox, you need to explicitly provide the username and password. Hence my original question, how does one extract the username and password of the User Account which is running the service applications.