Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

COM objects inside a NT service

1 view
Skip to first unread message

Brian Ross

unread,
Jul 22, 1999, 3:00:00 AM7/22/99
to
Hi,

I am trying to use an NT service to contain some COM objects and am running
into some problems. My problem is that whenever a program creates an
instance of my object when the service is running another copy of the server
is run instead of using the currently running instance. This is despite the
fact that the service registers the class object on startup.

Is there any special considerations that need to be taken when exporting COM
objects from a service that I don't know about?

Thanks
Brian


Paymaster

unread,
Jul 22, 1999, 3:00:00 AM7/22/99
to
It's got to do with security. Or, perhaps with the invokation mode flag
in your CreateInstance. I can't remember specifics and hopefully someone
else will give you a better answer, but at least you know where to look
in the meantime.

Brian Ross

unread,
Jul 22, 1999, 3:00:00 AM7/22/99
to
This is pretty much what I suspected but I don't know what I should be
looking for. Right now it is pretty oblivious to security (I pass in NULL
for any security parameters).

Do you think I should be looking at COM security issues or NT security
issues?

Paymaster <p...@paymaster.org> wrote in message
news:3796DD...@paymaster.org...

Patrick Philippot

unread,
Jul 22, 1999, 3:00:00 AM7/22/99
to
Brian,

You must use the ROT (running object table) to allow multiple clients to connect
to an already running object. I have sent sample code to your mailbox.

--
Patrick Philippot (MainSoft sarl)
patrick....@mainsoft.fr

Besoin d'aide en développement Windows?
Cliquez ici: http://www.mainsoft.fr
tel/fax: +33 (0)1 69 40 94 85


Alexander Nickolov

unread,
Jul 22, 1999, 3:00:00 AM7/22/99
to
You must specify specific NT account to run your service under. This
account must match the account in the NT services control panel
applet. Or you can use LocalSystem (or SYSTEM) at both places
which is preferred (if it is an option of course).

--
===============================
Alexander Nickolov, MCP
Panasonic Technologies Inc.
Speech Technology Laboratory
email: agnic...@geocities.com
===============================

Brian Ross wrote in message ...

Paymaster

unread,
Jul 22, 1999, 3:00:00 AM7/22/99
to
Brian Ross wrote:
>
> This is pretty much what I suspected but I don't know what I should be
> looking for. Right now it is pretty oblivious to security (I pass in NULL
> for any security parameters).
Have you run dcomcfg.exe and set your stuff there too? Not all can be
set programmatically. NULL's fine though <g>--for as much as it does.

> Do you think I should be looking at COM security issues or NT security
> issues?

Both, but probably mostly Com. Listen, I wish I could be more specific,
but I simply can't remember much <g>. Somewhere where you create an
instance there's also a flag that specifies some object creation options
(but again I can't remember the specifics.) There's a very good book
from Wrox books, by Miller (or Schiller, some Germain-like name.) It's
good, and it covers absolutely all there is about NT Services, and
there's a good-size chapter on Com servers packaged as NT services. Or
maybe someone here will come up with the answer, there are some pretty
good guys around here.

Good luck.
--
len
if you must email, reply to:
len bel at world net dot att dot net (no spaces, ats2@, dots2.)

Paymaster

unread,
Jul 22, 1999, 3:00:00 AM7/22/99
to
Patrick Philippot wrote:
> You must use the ROT (running object table) to allow multiple clients to connect
> to an already running object. I have sent sample code to your mailbox.
That's not true, at least as a general case. I've used things
(ATL-based, singletons) that would accept all connections in a single
instance just fine, w/o launching a second executable or creating more
objects. I still thinks it's a security or invokation policy issue.

Alexander Nickolov

unread,
Jul 22, 1999, 3:00:00 AM7/22/99
to
'Professional NT Services' by Kevin Miller, Wrox Press.

But I think you're wrong about the creation function. Or at least
it doesn't come to me what you're pointing at... The creation
function CoCreateInstanceEx accepts COSERVERINFO and
context (CLSCTX_XXX values). None of these deal specifically
with services. In fact the client never knows if the server is
NT service or not - only the OS knows that.

--
===============================
Alexander Nickolov, MCP
Panasonic Technologies Inc.
Speech Technology Laboratory
email: agnic...@geocities.com
===============================

Paymaster wrote in message <379710...@paymaster.org>...

Paymaster

unread,
Jul 22, 1999, 3:00:00 AM7/22/99
to
Alexander Nickolov wrote:
>
> 'Professional NT Services' by Kevin Miller, Wrox Press.
Yup, that's it. A very good book.

> But I think you're wrong about the creation function. Or at least
> it doesn't come to me what you're pointing at...

Aaaah, you're pushing me to look it up <g>. I can't remember, perhaps
I'm making it up, but I seem to remember that there's a place somewhere
where you say if you want un-shared access (in which case a new server
will be launched for every new security entity), or hitting the same
thing is acceptable even by different accounts. I might be mixing it up
with Corba "strategies", but... eh... <g>. I can't remember.

> ...CoCreateInstanceEx accepts COSERVERINFO and


> context (CLSCTX_XXX values). None of these deal specifically
> with services.

No, no, services got nothing to do with it. I launches the same server
several times not because it's a service, it's a security thing. Well,
I'm over my head right now <g>.

> In fact the client never knows if the server is
> NT service or not - only the OS knows that.

Right.

Girish Bharadwaj[mvp]

unread,
Jul 23, 1999, 3:00:00 AM7/23/99
to
>Aaaah, you're pushing me to look it up <g>. I can't remember, perhaps
>I'm making it up, but I seem to remember that there's a place somewhere
>where you say if you want un-shared access (in which case a new server
>will be launched for every new security entity), or hitting the same

Are you talking about the security Identity set as "Launching User"?


On Thu, 22 Jul 1999 21:49:30 +0600, Paymaster <p...@paymaster.org>
wrote:

Girish Bharadwaj [mvp].
Please do not email queries to me.
Post them in newsgroups.
Thank you.


Piers Coleman

unread,
Jul 23, 1999, 3:00:00 AM7/23/99
to
Alexander is correct, Mr. Paymaster is correct, and Patrick has a solution
to your problem if a separate server exe instance is still being created.

It is all to do with your 'window station'. There is an excellent kb
article that describes your problem in detail. It is:
' INFO: COM Servers Activation and NT Windows Stations' - Article ID:
Q169321

You may also want to reference the following doc if you still get multiple
exe's being created:

'FILE: Bind to an object on a Remote Machine Using ROT' - article ID Q171974

HTH, Piers

Brian Ross

unread,
Jul 23, 1999, 3:00:00 AM7/23/99
to
Thanks to everyone who helped... I found out what part of the problem was.
It turns out that when you are implementing a com class inside an NT service
you need to specify "LocalService" under the AppID for that class. It lets
COM know that it shouldn't use the LocalServer32 and should start the
service instead (if it hasn't already been started).

I am still having a problem however. Now that it uses the same instance of
the object (or starts it if it isn't started already... this time properly
as a service)... I am getting an "Access Denied" error when the object is
created. I suspect this has to do with the DCOM permissions but I tried to
give everyone full access to my class using DCOMCFG and it still gives me
access denied....

Any ideas?

John Duddy

unread,
Jul 23, 1999, 3:00:00 AM7/23/99
to
Perhaps the launching user does not have access to some critical system
resource (like HKEY_LOCAL_MACHINE)?

JD

Brian Ross wrote in message ...

Brian Ross

unread,
Jul 23, 1999, 3:00:00 AM7/23/99
to
I am running the test application as myself which has administrator
priviledges on both the machine and domain so I would assume that if it is
using my ID then there shouldn't be and access problems. Unless the COM
server is rejecting everyone of course.

Hmm.. I wonder if the access denied is being returned by the server when it
is trying to start and not a client side access problem.. Something to look
into on monday :)

> Perhaps the launching user does not have access to some critical system
> resource (like HKEY_LOCAL_MACHINE)?

> Brian Ross wrote in message ...

Marc Landes

unread,
Jul 26, 1999, 3:00:00 AM7/26/99
to
Brian Ross wrote in message ...
> I am still having a problem however. Now that it uses the same instance of
> the object (or starts it if it isn't started already... this time properly
> as a service)... I am getting an "Access Denied" error when the object is
> created. I suspect this has to do with the DCOM permissions but I tried to
> give everyone full access to my class using DCOMCFG and it still gives me
> access denied....

Do you use ConnectionPoints ?
If yes, which method returns Access denied : QueryInterface or Advise ?
Is your client written in VB or VC++ ?

Brian Ross

unread,
Jul 26, 1999, 3:00:00 AM7/26/99
to

I wasn't using connection points or anything else. I did find out what my
problem was though. It turns out that I have to specify an account for the
service to log in as. Using the system account doesn't allow other users to
have access to the component regardless of the permissions you explicitely
set for the component. Once I did this everything started to work as it
should.

Thanks to everyone who helped :)

Alex

unread,
Jul 27, 1999, 3:00:00 AM7/27/99
to
Hi Brian:
Did you manage to do this programmatically? or did you use DCOMCFG?

Brian Ross

unread,
Jul 27, 1999, 3:00:00 AM7/27/99
to
In the end I managed to do everything I needed without using DCOMCNFG at
all... The last problem was an NT service issue and I needed to specify the
username/password in the call to CreateService when the service was being
installed. Everything else is setup by using the standard registry
functions.
0 new messages