Re: WNetAddConnection2 to connect computer root
- From: John Shell <nospam@xxxxxxxxx>
- Date: Thu, 31 Aug 2006 15:45:15 -0400
On Wed, 30 Aug 2006 14:35:02 -0700, "Eugene Gershnik"
<gershnik@xxxxxxxxxxx> wrote:
These are some good points and good ideas. However, because this is
Well you have two alternatives. Either deploy an agent on each box or use
[W]Net APIs as you are doing.
With regards to Net API one thing you probably have to do is to run the
gathering part of your app as a service under a designated user account. If
you run it as an interactive user or LocalSystem you risk conflicts with
other applications or interactive user. Imagine what would happen if the
user were browsing files on a remote box in explorer and you started to
cancel connections or change credentials for the same box. Remember, all
application in a single logon session share Net connections definitions and
credentials. If you run in a service as a designated user I see no problem
keeping connections as long as you want. The interactive part can use COM
(with proper security enabled) to talk to the service.
just a VBA program running in MS Excel, I would like to keep it as
simple as possible. So what I decided to do is this:
When connecting to a machine, I first attempt to cancel any current
connection to it. However, I don't 'force' it, so if the user has a
connection open, it won't mess with it. If there is an error in
canceling the connection (other than ERROR_NOT_CONNECTED), I then
attempt to access the machine using the current connection. I do this
by calling WNetOpenEnum. If that fails, then return failure, otherwise
success.
If the cancel is okay, I then check the username. If it is null, I
attempt to access the machine using WNetOpenEnum as above. If it is
not null, I attempt to connect to the machine with the
username/password using WNetAddConnection2. If that succeeds, then
return success. If there was an error with the credentials, I prompt
the user for the username and password again. Otherwise, I attempt the
WNetOpenEnum to see if the machine is available without credentials.
I know it might seem better to just try the WNetOpenEnum first thing.
However, the above approach provides a chance to verify the
username/password (as long as the cancel doesn't fail).
With regards to an agent this is not as bad as it sounds. There are ways toOooo, a secret agent--sounds intriguing! ;-) Actually, the alternative
remotely deploy applications that maight make this option attractive.
on which I'm working is to have a central repository for all of the
data from all of the machines, so that reports can still be generated
when a machine is offline. However, right now, the approach I'm
planning on taking is to have the repository computer periodically
pull the data from the machines instead of having the machines push
their data to the repository.
Another issue is the username/password file you mentioned. Unless you areThat's a good point. However, right now, for our first customer of
very careful with file ACLs this might create a big hole in security.
this software, the username/password will probably usually be
guest/passme, but this is likely to be an issue with which I will need
to deal in later versions.
Thank you very much, Eugene, for your ideas. They are appreciated.
John
.
- References:
- WNetAddConnection2 to connect computer root
- From: John Shell
- Re: WNetAddConnection2 to connect computer root
- From: Eugene Gershnik
- Re: WNetAddConnection2 to connect computer root
- From: John Shell
- Re: WNetAddConnection2 to connect computer root
- From: Eugene Gershnik
- Re: WNetAddConnection2 to connect computer root
- From: John Shell
- Re: WNetAddConnection2 to connect computer root
- From: John Shell
- Re: WNetAddConnection2 to connect computer root
- From: Eugene Gershnik
- Re: WNetAddConnection2 to connect computer root
- From: John Shell
- Re: WNetAddConnection2 to connect computer root
- From: Eugene Gershnik
- WNetAddConnection2 to connect computer root
- Prev by Date: Re: How to send a data and closesocket immediately?????
- Next by Date: Re: html email
- Previous by thread: Re: WNetAddConnection2 to connect computer root
- Next by thread: Re: Specifiyig L2TP VPNs from RasDial/Entry ..
- Index(es):
Relevant Pages
|