View Full Version : Anyone know how to test that a user belongs to a user group?

07-09-2004, 01:04 PM
My installation creates an Oracle database and runs some Oracle SQL scripts. I need to know that the user performing the installation is a member of the user group ORA_DBA.

I can use the Is function to test that they are an administrator but is there any way of testing that a user belongs to any named group? In this case ORA_DBA.

Any help would be greatly appreciated.

By the way if anyone wants the InstallScript code to identify that Oracle is installed and to determine the Oracle Home I'll be happy to share it.

09-08-2004, 04:05 PM
I,m not sure about how to check for group membership, but I would be interested in seeing your code. I am just starting to add Oracle support to my current installation.



Christopher Painter
09-08-2004, 04:49 PM
If you are talking about an NT4 style local group or global group you can use the WINNT provider for ADSI. Here is an example of creating an account and placing it in the Users group. Hunt around on MSDN for more info on the object model and you should figure out how to check if a user is in a group. If not, ask me tomorrow and I'll give you a snippet.

If your talking about a ActiveDirectory directory it gets a little more difficult but still not too hard.

GetEnvVar ( "COMPUTERNAME", svComputerName );
set objComputer = CoGetObject("WinNT://"+svComputerName+",computer", "");
set objUser = objComputer.Create("user", "SOMEUSER");
set objUsersGroup = CoGetObjectobjUser.SetPassword("CENSORED");

("WinNT://"+svComputerName+"/Users,group", "");

09-29-2004, 01:09 PM
Here is the code that will find the home location and name for an installed Oracle product. I added a globals.rul file which I place this code into, I can then call it from any part of my installation script:-

// Include Ifx.h for built-in InstallScript function prototypes.
//#include "Ifx.h"

// Defined globally
string ora9iDir;

export prototype number findOra9i(BYREF string);

// findOra9i
// Function to determine the path of Oracle 9i Home if Oracle 9i is installed
function findOra9i(ora9iPath)
number nResult, nvSize, fileFound, nType;
LIST listResults;
string subKey, valueName, szMsg;

listResults = ListCreate(STRINGLIST);
fileFound = 0;

if (listResults = LIST_NULL) then
MessageBox ("Unable to create necessary lists.", SEVERE);


nResult = RegDBQueryKey ( "SOFTWARE\\ORACLE\\ALL_HOMES" , REGDB_KEYS , listResults );
if (nResult == 0) then // we found some subKeys

nResult = ListGetFirstString(listResults, subKey);

while ((nResult != END_OF_LIST) && (!fileFound))
subKey = "SOFTWARE\\ORACLE\\ALL_HOMES\\" + subKey;
valueName = "PATH";
nvSize = -1;

nResult = RegDBGetKeyValueEx(subKey, valueName, nType, ora9iPath, nvSize);
if nResult == 0 then
nResult = FindFile ( ora9iPath + "\\bin" , "ORACORE9.dll" , valueName );
if nResult == 0
then fileFound = 1;

if !fileFound then
nResult = ListGetNextString (listResults, subKey);

return fileFound;

09-30-2004, 11:38 AM
Maybe you can use this tool: Ifmember.exe

IfMember is a command-line tool that checks whether the current user is a member of a specified group. It is typically used in Windows logon scripts and other batch files.

Always check the Resource Kit tools for Windows.

10-18-2004, 03:29 PM
I saw the code on how to find if Oracle exists and the ORACLE_HOME. I had a different way to achieve this if Oracle was running on the same host as installsheild. My challenge is when I am installing the application the Oracle Server may actually be on another machine and although I can blindly run the scripts across the Oracle Net, I need to first make sure that the server exists on the other Host. I can do this simply by parsing through an output file with the output of a TNSPING, but is there a neater or slicker solution I can implement?
I will be on Win2K3 and using InstallshieldX. Thanks for your help.