Link to home
Start Free TrialLog in
Avatar of deniX23
deniX23

asked on

Network access

Hi, i need to access a unc directory from my application. The user running the program has access to the domain, but my app is running as a system service and therefore i don't have the network privelages. Is there anyway to give my process access to the domain (using my own username and password for the domain), and not with ImpersonateLoggedOnUser() because i would like it to work even when a user without access to the domain is logged in (using my own uname/pwd).

thanks
Avatar of Axter
Axter
Flag of United States of America image

Hi deniX23,
> >using my own uname/pwd).
You can change the service option to use your user name and password.

David Maisonave :-)
Cheers!
Avatar of deniX23
deniX23

ASKER

It's not running on my computer and i can't have it showing my username under "Username" in the task manager (i'd like to have it continue running under SYSTEM).
The CreateService API function takes the username and password as the last two arguments.
deniX23,
> >It's not running on my computer and i can't have it showing my username
> >under "Username" in the task manager

Why not?

David Maisonave :-}
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of deniX23

ASKER

Thanks!
You're welcome - BTW, don't forget to 'WNetCancelConnection2()' when you're done.
Avatar of deniX23

ASKER

What do i pass as paramater 1 to WNetCancelConnection2()?
Passing what i wrote in nr.lpRemoteName doesnt seem to work, the connection stays open (WNetCancelConnection2 returned 0)
Yes. You need to pass "\\\\server\\share" , as in 'nr.lpRemoteName'.

>>WNetCancelConnection2 returned 0

That means 'NO_ERROR' :o)
Avatar of deniX23

ASKER

I know the return value is ok thats the problem :),
before calling WNetAddConnection2  with "\\\\server\\share" i can't create files there. After calling it i can create files there, but after calling WNetCancelConnection2  with  "\\\\server\\share" i can still create files there... (even if i close and restart the service it continues to have access even without calling AddConnection. only after rebooting does it finally lose access).
Are you setting 'CONNECT_UPDATE_PROFILE' in the flags?
Avatar of deniX23

ASKER

:) Thanks!