Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIX_ACCOUNT_ADMINISTRATORS does not work as expected when trying add user to local Administrators group #4827

Open
wixbot opened this issue Jul 21, 2015 · 3 comments

Comments

@wixbot
Copy link

wixbot commented Jul 21, 2015

Consider the following fragment that is expected to create new local account and add it to local Administrators group, regardless the group name (such as on non-English systems)

<util:Group Id="AdminsGroup" Name="[WIX_ACCOUNT_ADMINISTRATORS]"/>
...
<util:User Id="CustomAdmin" CreateUser="yes" FailIfExists="no" Name="[CUSTOMADMINNAME]" Password="[INITIALPASSWORD]" PasswordNeverExpires="yes" CanNotChangePassword="yes" RemoveOnUninstall="yes">
<util:GroupRef Id="AdminsGroup"/>
/util:User

Fragment compiles successflly, but upon execution, it fails with 0x80004002 "Cannot add user to group BUILTIN\Administrators"

Note: In case that group name is different, such as on localized Windows, group name changes appropriately, so group name resolution is OK.

Problem is most likely caused by BUILTIN prefix in group name - if removed from group name, everything works as expected

Can the behavior can be fixed so as the logic could work? One easy option could be to introduce new variable, such as WIX_ACCOUNT_ADMINISTRATORS_NAME, that would contain group name without BUILTIN prefix

Thanks,
Jiri

Originally opened by jiri.formacek

@wixbot
Copy link
Author

wixbot commented Jul 21, 2015

Release changed from v3.10 to v3.x
Type changed from Bug to Feature

@wixbot
Copy link
Author

wixbot commented Aug 4, 2015

FYI - what I do in my mba is:
string aSID = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null).ToString();
string domain_adminsGroupName = new System.Security.Principal.SecurityIdentifier(aSID).Translate(typeof(System.Security.Principal.NTAccount)).ToString();
this._adminsGroupName = domain_adminsGroupName.Split('').Last();

                Then I pass AdminsGroupName down as a remembered property to:
                    <util:Group Id="AdminsGroup" Name="[ADMINSGROUPNAME]"/>

Originally posted by phogland

@wixbot
Copy link
Author

wixbot commented Aug 4, 2015

FYI - Also the code I posted supports multiple languages, particularly German, which is where I had issues before implementing this code about a year ago, shipping in many bundles.

Originally posted by phogland

@wixbot wixbot added this to the v3.x milestone Dec 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant