473,756 Members | 4,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET Remoting Return SecurityExcepti on 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
ChannelSinkProv ider 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
[PrinciplePermis sionAttribute(S ecurityAction.D emand, Role="Administr ator")]
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 SecurityExcepti on 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 2037
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...

[PrinciplePermis sionAttribute(S ecurityAction.D emand, Role="GroupMemb er")]
public RemoteableObjec t GetData()
{
RemoteableObjec t thisRemObj = new RemoteableObjec t();

// 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 AccessRemoteObj ect()
{
IGetData data =
(IGetData)Activ ator.GetObject( typeof(IGetData ),string.Format ("tcp://{0}:{1}/{2}/GetData",Server ,PortNumber , ApplicationName ));
RemoteableObjec t RO = new RemoteableObjec t();
try {
RO = data.GetData()
}
catch (SecurityExcept ion se) {
Trace.Write(se. Message.ToStrin g());
}
}

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
3072
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 them in asynchronous mode). Here's the situation just so you guys understand why I'm doing this (and maybe so that you can provide me with other options): I have an application that needs to save data to a remote database. The
0
246
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 ExceptionDispatch.MessageObjectSerialise cannot be accessed. ---> System.Security.SecurityException: Request failed. at
2
3081
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 ExceptionDispatch.MessageObjectSerialise cannot be accessed. ---> System.Security.SecurityException: Request failed. at
0
3403
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); I get the following error - doesn't matter if I try it local from my machine or from a remote machine. (After the Errormessage is more text ;))
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.