all groups > dotnet remoting > may 2007 >
You're in the

dotnet remoting

group:

Remoting Questions


Remoting Questions Wimpie van Lingen
5/18/2007 7:18:13 PM
dotnet remoting:
Hey

I have some more questions with regards to Remoting in .NET 2. I'm using TCP
with the Binary formatter.

My solution consists of 4 projects:
- Class Library containing the server classes which Inherits
MarshalByRefObject (ok, at this stage it only contains one class... but its
gonna grow)
- Class Library containing common classes and interfaces that will be shared
between all projects. This include interfaces for the server objects so the
clients won't have to reference the server class library directly and
serializable objects like UserInfo, etc.
- Console Application that will host the server classes. Will later convert
this to a Windows Service
- Windows forms application that will serve as the user interface

Ok, so this setup works. I've created a login form on the client, a
UserIdentity class and ISecurityManagement interface in the common class
library and a SecurityManagement class on the server.
So my code looks basically like this:
When the app starts, the following code executes:

Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As
ApplicationServices.StartupEventArgs) Handles Me.Startup

RemotingConfiguration.ApplicationName = "MyApplication"

Channels.ChannelServices.RegisterChannel(New Channels.Tcp.TcpChannel,
True)

Dim strUrl As String = My.Settings.Protocol & "://" & My.Settings.Server
& ":" & My.Settings.Port.ToString.Trim
'This basically translates to "tcp://10.0.0.11:1981'
My.Application.ServerUrl = strUrl

RemotingConfiguration.RegisterWellKnownServiceType
(GetType(ISecurityManagement), _
strUrl & "/SecurityManagement.rem", _
WellKnownObjectMode.SingleCall)
LoginForm.ShowDialog()

End Sub

When the user clicks Login, the following code executes:

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OK.Click

Dim args() As Object = Nothing
Try
Dim serverObj As ISecurityManagement = _
Activator.GetObject(
GetType(CommonLib.ServerInterfaces.ISecurityManage ment), _
My.Application.ServerUrl & "/SecurityManagement.rem")

Dim Usr As CommonLib.Security.UserIdentity =
ServerObj.Login(txtUsername.Text, txtPassword.Text)

MsgBox(Usr.ToString)
Me.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub


Ok, this works if I'm working on one computer as long as the Console
Application / Service hosting the server components are running. The problem
I have is that as soon as I copy the client exe with the CommonLib.dll over
to another computer, it doesn't work. I get an error message when attempting
to log on (the code in brown).
If the service / console application is not running, I get a connection
error, which is great because it tells me the app is trying to connect to
the correct location. This error obviously occurs on both computers.
If I do start the service / console app, the client located on my computer
works fine. The client on the other computer gives me the error:
"The server has rejected the client credentials."
If I set the EnsureSecurity option to False when registering the channel
(code marked in orange), the application freeze on that line and I either
have to stop the service to raise an error or terminate the client app.
Any idea how I can fix this?


Next question. The line of code marked in Navy. The application works if I
leave that line in or if I remove it either way. So what is the use to have
that code there if it doesn't affect whether the app works or not?


Finally I have a question about which type of remoting objects would work
best for my app.
Here are some details on my app:

The database and the components talking directly to the database will be
located on the server. On the client side, the windows forms will be quite a
large application that will communicate with the server components.
They will for instance, open the Training Module and there they will
constantly be busy filtering training records, scheduling new training,
cancelling training, etc. Almost for every action they take there will be
call(s) made to the database.

Remoting will be done over TCP with a binary formatter.

So what would be the best way to create the server components?
SingleCall, connection to the database is created and opened each time a
call is made to the object.
or
Singleton where one connection will be created for the application and
Opened / Closed for each call.

I don't know too much about remoting at this stage so I don't know all my
options. If someone has some suggestions, please post 'em.


Thanks

William

Solution: "The server has rejected the client credentials." Wimpie van Lingen
5/19/2007 3:24:33 AM
Ok... After LOOOONG research on the web, MSDN, newsgroups and posting on =
various VB forums and trying basically everything I could thought of, I =
found only one post that eventually put me on the right track to solve =
the error "The server has rejected the client credentials."=20
(the solution to my first problem) in the post below.=20

So, to save time for other people in the future, here it is:=20

1. In ControlPanel --> AdministrativeTools --> LocalSecuritySettings --> =

UserRightsAssignment, Add either 'Everyone' or 'AuthenticatedUsers' to =
the=20
'Access This Computer From The Network' Policy. (This might be what is=20
happening when a printer or folder is shared)=20

2. In ControlPanel --> AdministrativeTools --> LocalSecuritySettings --> =

SecurityOptions, Set the 'Network access: Sharing and security model for =

local accounts' to 'classic - local users authenticate as themselves'. =
(I=20
think this solves the second issue. if this is not done then =
impersonation=20
and also 'protectionLevel' other than 'None' does not work.=20

3. If 'impersonate' is set to true on the server side, the=20
'tokenImpersonationLevel' on the client has to be 'Impersonation' or=20
'Delegation'.=20

In my case, I only did task 1 above (Only added AuthenticatedUsers) on =
the computer hosting the components and that sorted out my problem.=20
For the full post, you can go to =
http://www.hightechtalks.com/dotnet-...or-392988.html

Regards=20

Wimpie


[quoted text, click to view]
RE: Remoting Questions calderara
5/21/2007 5:47:01 AM
hello,

I have made a remote component applciation where my server component is
storing data to a SQL database server on client request. the server is hoted
in a windows service running as Network service.
I am using tcp anf binary formatter for that.

My client has a reference to the proxy remote object and can call any public
function on remote server. It works locally or on any ditributed PC without
changinmg any line of code.

I just change the DNS nam of server location or the place of the staorage
database.
The only thing to know is that if you current client is running under BOB,
TCP chanel .NEt 2.0 trasfert credential automatically over channel sink. YOu
can then get the client user from the server by catching the CurrentThread
context and then do proper action.

It is clear also that if client application is running as BOB and you try to
reach a remote PC where your remote object is located, BOB account must exist
as well.

I do not change any settings your were talking about on your post

regard
serge

[quoted text, click to view]
Re: Remoting Questions Wimpie van Lingen
5/22/2007 12:00:00 AM
Hi

Maybe those settings are already set in place.
I tried having the same username and password on both computers and that
still didn't work


[quoted text, click to view]

Re: Remoting Questions calderara
5/22/2007 4:49:00 AM
hi,

I doubt that it is set by default becasue I am runing those under Vista OS
and security in there is much more lower than other platform..

have you try to reverse the situation in the sense that put your setting
back to original and then check that it will effectivly fail ?

have you check also the inner exception message ?
Any more erro in event logger ?

If you reaaly want to check that it comes from that try to run this small
sample remoting application console.
I have a link to the sample on my blog at :

http://www.wakespirit.spaces.live.com/

Run it as it is n same pc first, then change the tcp parmeter from config
file if to access server from remote Pc.

Hope it helps
regards
serge


[quoted text, click to view]
AddThis Social Bookmark Button