[wix-users] Custom action

Habib Salim habib at hsalim.com
Tue Nov 7 20:13:28 PST 2017


 A partial resolution and more information:
Even though the user running the installer is a domain administrator (and
a member of the local Administrators group)
principal.IsInRole(WindowsBuiltInRole.Administrator) always returns false
for me.  A few other people are seeing this as well.

However, it does not seem to matter in my case as I am able to enumerate
servers - partially.  
According to this KB article
https://msdn.microsoft.com/en-us/library/ms210334.aspx, SmoApplication may
not receive timely responses to the query so it may not list all available
servers.

I guess I can simply enter the server name and move on.


[CustomAction]
        public static ActionResult EnumerateSqlServers(Session session)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            session.Log("EnumerateSQLServers: Begin");

            // Check if running with admin rights and if not, log a
message to
            // let them know why it's failing.
            if (! HasAdminRights())
            {
                session.Log("EnumerateSQLServers: " + "ATTEMPTING TO RUN
WITHOUT ADMIN RIGHTS");
                //return ActionResult.Failure;
            }

            ActionResult result;

            DataTable dt = SmoApplication.EnumAvailableSqlServers(false);
            DataRow[] rows = dt.Select(string.Empty, "IsLocal desc, Name
asc");
            result = EnumSqlServersIntoComboBox(session, rows);

            session.Log("EnumerateSQLServers: End");
            return result;
        }


       private static bool HasAdminRights()
        {
            WindowsIdentity identity = WindowsIdentity.GetCurrent();
            var principal = new WindowsPrincipal(identity);
            return principal.IsInRole(WindowsBuiltInRole.Administrator);
        }





-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf
Of Habib Salim via wix-users
Sent: Tuesday, November 07, 2017 2:43 PM
To: 'WiX Toolset Users Mailing List' <wix-users at lists.wixtoolset.org>
Cc: Habib Salim <habib at hsalim.com>
Subject: [wix-users] Custom action

Hi
I copied Shane KM's code
https://stackoverflow.com/questions/14480837/wix-database-deployment-insta
llation
And of course modified it a fair bit.  Like Shane, I am adding a dialog to
show available SQL servers and to create a SQL database on the selected
server.
(then create SQL objects.)

The installer fails at EnumerateSqlServers

The installing user has Admin rights.  I'm stumped.

Thanks in advance for any help.
Regards
Habib




Here is the relevant portion of the install log:

SFXCA: Binding to CLR version v2.0.50727 Calling custom action
WixDbInstall!HSalimCo.CustomActions.EnumerateSqlServers
EnumerateSQLServers: Begin
EnumerateSQLServers: ATTEMPTING TO RUN WITHOUT ADMIN RIGHTS CustomAction
EnumerateSqlServers returned actual error code 1603 (note this may not be
100% accurate if translation happened inside sandbox) Action ended
11:15:13: EnumerateSqlServers. Return value 3.
MSI (c) (00:2C) [11:15:13:853]: Doing action: FatalError MSI (c) (00:2C)
[11:15:13:853]: Note: 1: 2205 2:  3: ActionText Action 11:15:13:
FatalError.
Action start 11:15:13: FatalError.
Action 11:15:13: FatalError. Dialog created

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant
http://www.firegiant.com/



More information about the wix-users mailing list