views:

254

answers:

2

In an InstallShield basic MSI project: how can I check whether a user name is in the administrator group?

(Not the current user with which I know it's possible to do so.)

+1  A: 

You could run "net localgroup administrators" and parse the output. I suspect there is a better way, but if not...

jeffamaphone
thanks for the quick reply. Although in this way, if a group is added to the admin group, we still need to figure out if the user is in that group.
Peter
A: 

Users can belong to the 'Administrators' group on the local server or could be part of the 'Domain Admins' or 'Enterprise Admins' groups defined inside your AD. Ideal solution would be to create a DLL with a method called IsUserAdmin(user_name) that takes in a user name parameter and returns either true or false.

Internally, the method will call the IADsUser::Groups method to determine the groups the supplied user belongs to and will return true if the groups enumerated belongs to one of those administrator groups above. If not it will return false. You may invoke this DLL inside your InstallShield projects. Be wary of nested groups.

msvcyc
thx, we may also do this in a vbscript which is supported in InstallShield custom actions. Although i'm still wondering if there's already a similar function in some win32 dll that i can call directly.
Peter