473,387 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

.NET Remoting Return SecurityException IMessage

Not that I've ever gotten any reponse to questions in the past, but I don't
know where else to turn.
I have a remoting application (.NET 2.0, VS 2005, C#) with a custom
ChannelSinkProvider as described in this article
http://msdn2.microsoft.com/en-us/library/ms973909.aspx

This example uses role-based security by way of decorating each method with
[PrinciplePermissionAttribute(SecurityAction.Demand , Role="Administrator")]
or some other programmer defined role.

It works fine... the problem is, the user has no idea why the action is not
being performed, it just silently fails if the user is not a member of the
specified role. I would like to capture this SecurityException message and
send it back to the user as a Response to their request, then handle the
Response by printing it to the status bar in the client application.

But I can't figure out where to capture this exception and create the
response message because it's an attribute on the method. Where would the
exception occur? My code is identical to the code at the above website.
Nov 7 '07 #1
4 2017
Yes, thank you very much Jialiang... your interpretation of my puzzlement was
right on base.

So, based on what you are telling me, I can simply capture the "Response"
from the method by placing the call from the remote client in a try{} catch
{} clause?

I don't need to append the denial message to the IMessage object in the
MessageSink chain?

Ultimately, this is what I'd like to get to... I have the Remote Server
running on a network machine which is a domain member. The clients are also
network machines within the same domain. The "services," which I call Remote
Objects are located on the server machine, as well, with similar signatures...

[PrinciplePermissionAttribute(SecurityAction.Demand , Role="GroupMember")]
public RemoteableObject GetData()
{
RemoteableObject thisRemObj = new RemoteableObject();

// do some work

return thisRemObj;
}

So in the client I would use the following pattern to access this Remote
Object through an Interface

private void AccessRemoteObject()
{
IGetData data =
(IGetData)Activator.GetObject(typeof(IGetData),str ing.Format("tcp://{0}:{1}/{2}/GetData",Server ,PortNumber , ApplicationName));
RemoteableObject RO = new RemoteableObject();
try {
RO = data.GetData()
}
catch (SecurityException se) {
Trace.Write(se.Message.ToString());
}
}

But I'll be using Asynchronous access, so I'm guessing this should also work
by way of a delegate within the client with a callBack handler... does this
sound pheasible?
Nov 8 '07 #2
Hello,

As we see, if it is a synchronous call, we can simply add the try {} catch
around the method data.GetData(). But if it is an asynchronous one, adding
the try {} catch around BeginInvoke may not help. We need to add the try
catch around the EndInvoke call in its call back function.

If you have any other question or need anything else, please feel free to
let me know.

Sincerely,
Jialiang Ge (ji****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Nov 9 '07 #3
Hello,

Would you mind letting me know the result of the suggestions. Please feel
free to let me know if you further questions or concerns.

Sincerely,
Jialiang Ge (ji****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Nov 13 '07 #4
Yes, thank you very much for your help. The first post led me to the correct
capture location where I was able to communicate back to the user, the
results of their request. This also works in the callback of an asynchronous
request.

Thanks again,

Sam Martinez
Nov 13 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Skip | last post by:
Hi, I'm new to .NET remoting and there's something I'm having real trouble with. Basically, I'd like to create a component that can act as a server and as a client (can send messages and receive...
0
by: DC | last post by:
Hi, I am trying to serialise an object across remoting, and I get the following message: System.Runtime.Serialization.SerializationException: Because of security restrictions, the type...
2
by: DC | last post by:
Hi, I am trying to serialise an object across remoting, and I get the following message: System.Runtime.Serialization.SerializationException: Because of security restrictions, the type...
0
by: Kristian Reukauff | last post by:
Hi I have a problem with the .Net-Securty-Functions. I've got a client and a server. When I try to register a channel at the server with this line: ChannelServices.RegisterChannel(chan, false);...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.