Home All Groups Group Topic Archive Search About

Access file on another pc (out of domain) with username and passwo

Author
4 Aug 2006 1:06 PM
Stefano C.
I neeed to write a Windows Service that have to access files on a server in
our network (without domain).
-Our network have NO domain.
-Service run on a win 2003 Server (SERVER_A)
-Files are in a Win 2000 server (SERVER_B)
I have to read and write files in SERVER_B with a specific user (Ex.:
SERVER_B\Jonh) and password (Ex.: 1234) ho can i do that?
I have tried LogonUser API (advapi32.dll) but don't resolve my problem.
Thanks
Ste.

Author
4 Aug 2006 4:23 PM
Mike Lowery
I think if you change the logon properties for the service (run services.msc) to
match the account you want to use on the remote box, it should work.  You have
to ensure the same account and password exists on both boxes though.

Show quote
"Stefano C." <Stefa***@discussions.microsoft.com> wrote in message
news:68722DA8-B4A8-4F2A-92EA-12D3CCBCB22E@microsoft.com...
>I neeed to write a Windows Service that have to access files on a server in
> our network (without domain).
> -Our network have NO domain.
> -Service run on a win 2003 Server (SERVER_A)
> -Files are in a Win 2000 server (SERVER_B)
> I have to read and write files in SERVER_B with a specific user (Ex.:
> SERVER_B\Jonh) and password (Ex.: 1234) ho can i do that?
> I have tried LogonUser API (advapi32.dll) but don't resolve my problem.
> Thanks
> Ste.
Author
4 Aug 2006 5:38 PM
David Browne
"Mike Lowery" <selfspam@mouse-potato.com> wrote in message
news:eP58jJ%23tGHA.4748@TK2MSFTNGP03.phx.gbl...
>I think if you change the logon properties for the service (run
>services.msc) to match the account you want to use on the remote box, it
>should work.  You have to ensure the same account and password exists on
>both boxes though.
>

This is called "workgroup authentication" and it is the only reliable way to
access remote files through windows networking outside of a domain without
an interactive user.

You can access network resources by suppling a user name and password
through the "net use" functionality, or programmatically through the
WNetAddConnection2 API.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetaddconnection2.asp

But this is really more for interactive users.  There are a number of
limitations that make this work poorly for services.

David
Author
8 Aug 2006 10:42 PM
Stefano C.
Sorry for my delay in answering.
Now it works fine.
Thankyou Mike and David

Show quote
"David Browne" wrote:

>
> "Mike Lowery" <selfspam@mouse-potato.com> wrote in message
> news:eP58jJ%23tGHA.4748@TK2MSFTNGP03.phx.gbl...
> >I think if you change the logon properties for the service (run
> >services.msc) to match the account you want to use on the remote box, it
> >should work.  You have to ensure the same account and password exists on
> >both boxes though.
> >
>
> This is called "workgroup authentication" and it is the only reliable way to
> access remote files through windows networking outside of a domain without
> an interactive user.
>
> You can access network resources by suppling a user name and password
> through the "net use" functionality, or programmatically through the
> WNetAddConnection2 API.
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetaddconnection2.asp
>
> But this is really more for interactive users.  There are a number of
> limitations that make this work poorly for services.
>
> David
>
>
>
>

AddThis Social Bookmark Button