If your using Windows NT 4.0 then the localsystem account does not have
network access. If this is Windows 2000+, then network access is allowed.
This, however, may not be your problem. In fact I do believe that you are
missing part of the equation. Try using "computername\user" as the user to
log in.


"Frédéric" wrote in message
> Hi,
> I'm a trying to connect a network device through a service that is running
> as LocalSystem.
> I tried the function WNetAddConnection2, but calling this function returns
> error code 1312.
> This works perfectly well if I run the service in debug mode, but I get

> above error code if I start it from the Service Controler as LocalSystem.
> The problem is that the error code 1312 isn't supposed to be a possible
> return value for WNetAddConnection2. So I can't figure out what is going
> wrong...
> If someone could tell me what I'm doing wrong, this would be greatly
> appreciated...
> This is the way I use WNetAddConnection2:
> NETRESOURCE NetResource;
> NetResource.dwType = RESOURCETYPE_ANY;
> NetResource.lpLocalName = NULL;
> NetResource.lpRemoteName = "\\\\tatihou\\download";
> NetResource.lpProvider = NULL;
> WNetAddConnection2(
> &NetResource,
> "password1",
> "user1",
> 0);
> NB: user1 is a valid user on remote computer tatihou and his password is
> password1;
> The resource "download" is correctly shared and mounting this resource

> paramaters user1/password1 works ok through an explorer...
> Thanks for your help,
> Fred