Programmatically determine the account under which a servi..

Chris

Distinguished
Dec 7, 2003
2,048
0
19,780
Archived from groups: microsoft.public.win2000.security (More info?)

Hello,

I'm looking for a C++ code snippet that would help determine the 'log on as'
account for a Windows service, MSSQLSERVER, for example.

Any help appreciated!

--
Chris
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.security (More info?)

Check out QueryServiceConfig.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/queryserviceconfig.asp?frame=true

You could also probably use WMI but WMI is such a pain that it generally isn't
worth it, especially in C++.

--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net


Chris wrote:
> Hello,
>
> I'm looking for a C++ code snippet that would help determine the 'log on as'
> account for a Windows service, MSSQLSERVER, for example.
>
> Any help appreciated!
>
 

Chris

Distinguished
Dec 7, 2003
2,048
0
19,780
Archived from groups: microsoft.public.win2000.security (More info?)

Thank you! That was very quick!!

I hate to be a doof - but, which is the 'log on as' parameter?

// Print the configuration information.

printf("\nSample_Srv configuration: \n");
printf(" Type: 0x%x\n", lpqscBuf->dwServiceType);
printf(" Start Type: 0x%x\n", lpqscBuf->dwStartType);
printf(" Error Control: 0x%x\n", lpqscBuf->dwErrorControl);
printf(" Binary path: %s\n", lpqscBuf->lpBinaryPathName);

if (lpqscBuf->lpLoadOrderGroup != NULL)
printf(" Load order group: %s\n", lpqscBuf->lpLoadOrderGroup);
if (lpqscBuf->dwTagId != 0)
printf(" Tag ID: %d\n", lpqscBuf->dwTagId);
if (lpqscBuf->lpDependencies != NULL)
printf(" Dependencies: %s\n", lpqscBuf->lpDependencies);
if (lpqscBuf->lpServiceStartName != NULL)
printf(" Start Name: %s\n", lpqscBuf->lpServiceStartName);
if (lpqscBuf2->lpDescription != NULL)
printf(" Description: %s\n", lpqscBuf2->lpDescription);

--
Chris


"Joe Richards [MVP]" wrote:

> Check out QueryServiceConfig.
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/queryserviceconfig.asp?frame=true
>
> You could also probably use WMI but WMI is such a pain that it generally isn't
> worth it, especially in C++.
>
> --
> Joe Richards Microsoft MVP Windows Server Directory Services
> www.joeware.net
>
>
> Chris wrote:
> > Hello,
> >
> > I'm looking for a C++ code snippet that would help determine the 'log on as'
> > account for a Windows service, MSSQLSERVER, for example.
> >
> > Any help appreciated!
> >
>
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.security (More info?)

"Chris" <Chris@discussions.microsoft.com> wrote in message
news:EF72359D-49E0-472D-B0BA-FD5ADB4714B1@microsoft.com...
> Thank you! That was very quick!!
>
> I hate to be a doof - but, which is the 'log on as' parameter?
>

StartName


> // Print the configuration information.
>
> printf("\nSample_Srv configuration: \n");
> printf(" Type: 0x%x\n", lpqscBuf->dwServiceType);
> printf(" Start Type: 0x%x\n", lpqscBuf->dwStartType);
> printf(" Error Control: 0x%x\n", lpqscBuf->dwErrorControl);
> printf(" Binary path: %s\n", lpqscBuf->lpBinaryPathName);
>
> if (lpqscBuf->lpLoadOrderGroup != NULL)
> printf(" Load order group: %s\n", lpqscBuf->lpLoadOrderGroup);
> if (lpqscBuf->dwTagId != 0)
> printf(" Tag ID: %d\n", lpqscBuf->dwTagId);
> if (lpqscBuf->lpDependencies != NULL)
> printf(" Dependencies: %s\n", lpqscBuf->lpDependencies);
> if (lpqscBuf->lpServiceStartName != NULL)
> printf(" Start Name: %s\n", lpqscBuf->lpServiceStartName);
> if (lpqscBuf2->lpDescription != NULL)
> printf(" Description: %s\n", lpqscBuf2->lpDescription);
>
> --
> Chris
>
>
> "Joe Richards [MVP]" wrote:
>
> > Check out QueryServiceConfig.
> >
> >
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/queryserviceconfig.asp?frame=true
> >
> > You could also probably use WMI but WMI is such a pain that it generally
isn't
> > worth it, especially in C++.
> >
> > --
> > Joe Richards Microsoft MVP Windows Server Directory Services
> > www.joeware.net
> >
> >
> > Chris wrote:
> > > Hello,
> > >
> > > I'm looking for a C++ code snippet that would help determine the 'log
on as'
> > > account for a Windows service, MSSQLSERVER, for example.
> > >
> > > Any help appreciated!
> > >
> >
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.security (More info?)

"Joe Richards [MVP]" <humorexpress@hotmail.com> wrote in message
news:eNOeVmUmFHA.1044@tk2msftngp13.phx.gbl...
> Check out QueryServiceConfig.
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/queryserviceconfig.asp?frame=true
>
> You could also probably use WMI but WMI is such a pain that it generally
isn't
> worth it, especially in C++.
>

I would bet that is more a C++ thing than a WMI thing.
IMO win32_Service object in WMI is extremely simple and handy
and I find its use remoted in a domain context quite acceptibly fast.
--
ra

>
> Chris wrote:
> > Hello,
> >
> > I'm looking for a C++ code snippet that would help determine the 'log on
as'
> > account for a Windows service, MSSQLSERVER, for example.
> >
> > Any help appreciated!
> >
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.security (More info?)

WMI seems to be ok for one off stuff. The times I have tried to use it in
monitoring or other things it tends to start to get screwy. OVO/W uses it and I
know the OVO/W SPI developers are moving to get away from it due to all of the
support issues they have encountered with it.

--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net


Roger Abell wrote:
> "Joe Richards [MVP]" <humorexpress@hotmail.com> wrote in message
> news:eNOeVmUmFHA.1044@tk2msftngp13.phx.gbl...
>
>>Check out QueryServiceConfig.
>>
>>
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/queryserviceconfig.asp?frame=true
>
>>You could also probably use WMI but WMI is such a pain that it generally
>
> isn't
>
>>worth it, especially in C++.
>>
>
>
> I would bet that is more a C++ thing than a WMI thing.
> IMO win32_Service object in WMI is extremely simple and handy
> and I find its use remoted in a domain context quite acceptibly fast.
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.security (More info?)

When a remote "gets toasted" relative to its WMI support then
yes, it can be trying to diag and get that machine's WMI support
whole again.

--
Roger Abell
Microsoft MVP (Windows Security)

"Joe Richards [MVP]" <humorexpress@hotmail.com> wrote in message
news:ur6frXimFHA.2580@TK2MSFTNGP09.phx.gbl...
> WMI seems to be ok for one off stuff. The times I have tried to use it in
> monitoring or other things it tends to start to get screwy. OVO/W uses it
and I
> know the OVO/W SPI developers are moving to get away from it due to all of
the
> support issues they have encountered with it.
>
> --
> Joe Richards Microsoft MVP Windows Server Directory Services
> www.joeware.net
>
>
> Roger Abell wrote:
> > "Joe Richards [MVP]" <humorexpress@hotmail.com> wrote in message
> > news:eNOeVmUmFHA.1044@tk2msftngp13.phx.gbl...
> >
> >>Check out QueryServiceConfig.
> >>
> >>
> >
> >
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/queryserviceconfig.asp?frame=true
> >
> >>You could also probably use WMI but WMI is such a pain that it generally
> >
> > isn't
> >
> >>worth it, especially in C++.
> >>
> >
> >
> > I would bet that is more a C++ thing than a WMI thing.
> > IMO win32_Service object in WMI is extremely simple and handy
> > and I find its use remoted in a domain context quite acceptibly fast.