How to logon to an NT Server

Hi everyone...

does sombody have an example how to logon to an NT Server? When I double click on an Server (Network Neighborhood) and I'm not in that domain, I will be asked for an username and password to access this server. How can I do this from within Delphi? I need to regulary access a server, but after every restart I have to logon manualy, which I would like to prevent :-)

Thanks, Jonny...
jonnyfiveAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RBertoraCommented:
I don't know how to do exactly what you want, but if you map a drive to that server you can effectively logon right:

here is how to map a drive:

To map to different PC harddrives use:

WNetAddConnection("\\Server\Path\", "pwd", "K:");

or WNetAdconnection2 :

procedure TForm1.Button1Click(Sender: TObject);
var
  Net : TNETRESOURCE;
begin

  with Net do
  begin
      dwScope := RESOURCE_CONNECTED ;
      dwType := RESOURCETYPE_DISK;
      dwDisplayType := RESOURCEDISPLAYTYPE_SHARE;
      dwUsage := RESOURCEUSAGE_CONNECTABLE;
      lpLocalName := 'K:';
      lpRemoteName := PChar('\\ntdata\foldername');
      lpComment := Pchar('None');
      lpProvider := Nil;
  end;

 WNetAddConnection2(Net,'Password','RBertora',CONNECT_UPDATE_PROFILE );

end;

Rob ;-)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RadlerCommented:
Well;

More points losted :-(

Your problem can be solved add a Trusted/Trusting Domain to/for your Local/Global Domain.

See yor User manager for domains at NT server and adjust like desired.

T++, Radler
0
jonnyfiveAuthor Commented:
Hi Radler...

I still have to review Robs solution (I will do this tommorow :-)... but a trust relation ship is not an option, since one is a coperate server which is controled by our IT department and the other one our local "staging" server. It's all about politics :-) But thanks anyway...

Regards, Jonny...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.