ATL Service: only one user with write rights 
Author Message
 ATL Service: only one user with write rights

Bonjour,

I would like your advise on how to proceed, here is what I need to do:

1- ATL service (I will make change recommanded by Kevin Miller in his
book Professional NT Services), i.e. service will be MTA. ATL service
will have about 4 ATL Simple Object(Free Threaded).
2- Two Clients: Asp (VBScript) and Visual C++ 6.0

When the ATL service starts, it will connect to another App (AppX).
This link will stay opened until the ATL service is stopped. There can
be communication between ATL Service and AppX without any client
connected to the ATL service ! I already did this part and it is
working fine.

There can be multiple client with read access rights (I will
synchronize access to the external data source). I have no problem
here ... yet !

Now here is my problem:

ATL service needs to know when a user is logged in with a
"reconfiguration account", i.e. user that has write access. Only one
is permitted at the same time. The reconf. user will be able to send
messages to AppX, using the communication link ... this is why I was
trying to do the "client counting ... see my previous post
CComModule::GetLockCount" ... it looked like a good place to start ?

Basically, I want to do something like this:
Client1 calls method ConnectReconf
Service checks if client1 can connect in reconf. mode ... no clients
are connected in reconf. mode
Client1 is granted access in reconf. mode (write / read access)
Client2 calls method ConnectReconf
Service checks if client2 can connect in reconf. mode ... oups, there
is someone else in reconf. mode
Client2 is refused access in reconf. mode but can still read data.
ect...

Should my ATL objects be singletons (does it have to be or can I go
without it) ?
What would be the best approach and potential problems ?

Merci,
Steph



Sun, 23 May 2004 05:57:38 GMT  
 ATL Service: only one user with write rights
The objects themselves need not be singletons. However, you do
need an internal singleton (C++) class that keeps track of the reconf
state. You do need synchronization of its data like with any other
piece of data.

A potential problem is a client crash. You should revoke the reconf
lock within the external object's destructor, if the client hasn't done
so explicitly. (This is also the reason a COM singleton object won't
work.) This  may incur up to 6 minutes of dead time until COM detects
the dead client and unloads the stub which in turm Release-s your
object.

If you want to keep a pointer to the current object which is granted
reconf access, you must AddRef it internally. Therefore, you need
to implement IExternalConnection on that object and let it detect
the client death in the ReleaseConnection method - not in the
destructor as I suggested above.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> Bonjour,

> I would like your advise on how to proceed, here is what I need to do:

> 1- ATL service (I will make change recommanded by Kevin Miller in his
> book Professional NT Services), i.e. service will be MTA. ATL service
> will have about 4 ATL Simple Object(Free Threaded).
> 2- Two Clients: Asp (vbscript) and Visual C++ 6.0

> When the ATL service starts, it will connect to another App (AppX).
> This link will stay opened until the ATL service is stopped. There can
> be communication between ATL Service and AppX without any client
> connected to the ATL service ! I already did this part and it is
> working fine.

> There can be multiple client with read access rights (I will
> synchronize access to the external data source). I have no problem
> here ... yet !

> Now here is my problem:

> ATL service needs to know when a user is logged in with a
> "reconfiguration account", i.e. user that has write access. Only one
> is permitted at the same time. The reconf. user will be able to send
> messages to AppX, using the communication link ... this is why I was
> trying to do the "client counting ... see my previous post
> CComModule::GetLockCount" ... it looked like a good place to start ?

> Basically, I want to do something like this:
> Client1 calls method ConnectReconf
> Service checks if client1 can connect in reconf. mode ... no clients
> are connected in reconf. mode
> Client1 is granted access in reconf. mode (write / read access)
> Client2 calls method ConnectReconf
> Service checks if client2 can connect in reconf. mode ... oups, there
> is someone else in reconf. mode
> Client2 is refused access in reconf. mode but can still read data.
> ect...

> Should my ATL objects be singletons (does it have to be or can I go
> without it) ?
> What would be the best approach and potential problems ?

> Merci,
> Steph



Mon, 24 May 2004 07:04:26 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Question about ATL services, where to put user code

2. Writing ATL NT Service

3. How to write services with ATL in VisualStudo.NET

4. How to write services with ATL in VisualStudio.NET

5. com+ service written in ATL?

6. writing NT win32 services with atl -help is needed

7. Good book about writing NT System services via ATL

8. info on writing Services using ATL

9. Writing service on atributed ATL project

10. Which one is the right one?

11. user change or change user rights for MS ACCESS DB with DAO (MFC)

12. Jet record locked by another user (only one user)

 

 
Powered by phpBB® Forum Software