wix - Determining IIS user for IIS 5 -


I am writing a Wix-based setup for a web application and would like to set permissions on the folders that install it. Can reach them.

Use IIS 6 and 7, respectively, using IIS_WPG and IIS_USRS , and uses IIS 5 IUSR_COMPUTER NAME . If the user has changed the name of his machine, however, the permissions of using the current computer name fails.

Is there a way to determine the user account in programming is being used by IIS 5, assuming that it would be IUSR_COMPUTERNAME ?

I am doing it like this (do not pretend to provide the best practice solution) - this is immediate CA sets the properties that you can use later:

 [custom action] public static action realt set IUSR account statement ( Session session) {Axcarsult ActionResult = Action Result Failer; DirectoryEntry iisAdmin = New DirectoryInter ("IIS: //LostalHost / W3SVC"); If (iisAdmin! = Null) {string iusrName = (string) iisAdmin.Properties ["anonymous user name"] [0]; If (! String.IsNullOrEmpty (iusrName)) {session ["IUSR_USERNAME"] = iusrName; String iusrDomain = GetAccountDomain (iusrName, session); If (! String.iusrDomain) {session ["IUSR_DOMAIN"] = iusrDomain; } Action = Execution. Success; }} Return Action Result; }  

Where the GetAccountDomain method is defined as:

  Fixed string GetAccountDomain (string account name , Session session) {SelectQuery query = new option ("Win32_UserAccount", string.Format ("name = '{0}'", accountName), new string [] {"domain"}); Management object explorer explorer = new management object search (query); {Foreach (the management object account in the finder.) ({} (Try the string account ["domain"];}} hold (exception before) {session.log ("Failed to get domain for user" 0}: {1} ", account, former.);} Return tap;}  

Hope this helps.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -