Oracle service starting through appln [message #314273] |
Wed, 16 April 2008 04:51 |
sgkharvi
Messages: 1 Registered: January 2008 Location: india
|
Junior Member |
|
|
hi,
in our application we have to block the windows access to users. so we r starting our application by running our application by shell command. since our appln uses oracle database and need to connect database in the beginning we are starting the oracle service using SCManger database,
this was working fine till we had administrator privilages. but now the user login is only member of USER group and after this OpenSCManger is not returning service control Manager database handle and we are not able to start our appln.
the code is as follows:
BOOL bServiceStart = FALSE;
while(!bServiceStart)
{
SERVICE_STATUS ssStatus;
DWORD dwOldCheckPoint;
SC_HANDLE schSCManager = OpenSCManager(
NULL, // local machine
NULL, // ServicesActive database
SC_MANAGER_ALL_ACCESS); // full access rights
if (schSCManager == NULL)
{
AfxMessageBox("Error OpenSCManager");
break;
}
SC_HANDLE schService = OpenService(
schSCManager, // SCM database
TEXT("OracleServiceXXX"), // service name
SERVICE_ALL_ACCESS);
if (schService == NULL)
{
OutputDebugString("Oracle: ERROR StartService\n");
break;
}
if (!StartService(
schService, // handle to service
0, // number of arguments
NULL) ) // no arguments
{
OutputDebugString("Oracle: Error StartService");
}
else
{
OutputDebugString("Oracle: Oracle Service starting\n");
}
// Check the status until the service is no longer start pending.
if (!QueryServiceStatus(
schService, // handle to service
&ssStatus) ) // address of status information
AfxMessageBox("Error QueryServiceStatus");
while (ssStatus.dwCurrentState == SERVICE_START_PENDING)
{
// Save the current checkpoint.
dwOldCheckPoint = ssStatus.dwCheckPoint;
// Wait for the specified interval.
Sleep(ssStatus.dwWaitHint);
// Check the status again.
if (!QueryServiceStatus(
schService, // handle to service
&ssStatus) ) // address of status information
break;
// Break if the checkpoint has not been incremented.
if (dwOldCheckPoint >= ssStatus.dwCheckPoint)
break;
}
if (ssStatus.dwCurrentState == SERVICE_RUNNING)
{
OutputDebugString("Oracle: Oracle Service is started \n");
bServiceStart = TRUE;
}
else
{
OutputDebugString("Oracle: ERROR StartService\n");
}
CloseServiceHandle(schService);
}
return bServiceStart;
is there any other method to start service for USER group login
kindly someone help us out??????????
thanks
|
|
|
|