I am trying impersonation in remoting .. The program runs fine when i turn off impersonation. I am running client and server both on the same machine(VISTA). I have created the user account on the machine .. and it runs fine when i use secure channel and turn impersonation off.. I have also checked that when impersonation is off and using secure channel .. it allows only the users that i have created to logon .. otherwise it gives authentication failure. Following is the code : Server: using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using System.Collections; using System.Threading; using System.Security.Principal; namespace ns_application { namespace ns_server { public class cls_server { static void Main(string[] args) { //TcpChannel channel = new TcpChannel(8080); IDictionary props = (IDictionary) new Hashtable(); IPrincipal threadPrincipal; props.Add("port", "8080"); props.Add("secure", "true"); props.Add("impersonate", "true"); props.Add("protectionLevel", "EncryptAndSign"); //props.Add("username", "Vishwjeet"); //props.Add("password", "pwd"); //props.Add("authorizationModule", "AuthorizeUser"); //BinaryClientFormatterSinkProvider cp = new BinaryClientFormatterSinkProvider(); //BinaryServerFormatterSinkProvider sp = new BinaryServerFormatterSinkProvider(); IChannel chan = new TcpChannel(props,null,null); ChannelServices.RegisterChannel(chan,true); RemotingConfiguration.RegisterWellKnownServiceType(typeof(ns_registeruser.cls_registeruser), "ApplicationMain", WellKnownObjectMode.Singleton); threadPrincipal = Thread.CurrentPrincipal; Console.WriteLine(threadPrincipal.Identity.Name); Console.WriteLine(threadPrincipal.Identity.IsAuthenticated); Console.WriteLine(threadPrincipal.Identity.AuthenticationType); Console.WriteLine("Server Started .. "); Console.ReadLine(); } } } } Methods : using System; using System.Runtime.Serialization; using System.Reflection; using System.Data; using System.Threading; using System.Security.Principal; namespace ns_application { namespace ns_registeruser { //[Serializable] public class cls_whereitruns:MarshalByRefObject { private int _IDNo; public int IDNo { get { return _IDNo; } set { _IDNo = value; } } public int FutureofID() { IDNo = IDNo * 5; Console.WriteLine("Calculated future of ID : {0} :::: {1} :::: {2}", IDNo,this.ToString(),AppDomain.CurrentDomain.FriendlyName); return(IDNo); } public cls_wher
vishwjeet
Posts
-
Impersonation throwing exception -
Impersonation throwing exceptionhmmm .. actaully this is happening while im trying remoting .. i can give u the code .. if u wanna see .. i am not able to find any message board for remoting .. so was trying my luck out here
-
Impersonation throwing exceptionAny help on this error?? This happens when I run the server with ID_A and try to run the client with ID_B .. this is an attempt to try impersonation System.TypeInitializationException was unhandled Message="The type initializer for 'System.Runtime.Remoting.Identity' threw an exception." Source="mscorlib" TypeName="System.Runtime.Remoting.Identity" StackTrace: Server stack trace: at System.Runtime.Remoting.Identity.RemoveAppNameOrAppGuidIfNecessary(String uri) at System.Runtime.Remoting.IdentityHolder.MakeURIKey(String uri) at System.Runtime.Remoting.IdentityHolder.ResolveIdentity(String URI) at System.Runtime.Remoting.RemotingServices.GetServerTypeForUri(String URI) at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at System.Object.FieldGetter(String typeName, String fieldName, Object& val) at ns_application.ns_client.cls_client.Main(String[] args) in D:\Vishwjeet\Study\Remoting_tcp\ConsoleApplication2\client.cs:line 64 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: System.Security.Cryptography.CryptographicException Message="Unknown error \"-2146893801\"." Source="mscorlib" StackTrace: at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr) at System.Security.Cryptography.Utils._AcquireCSP(CspParameters param, SafeProvHandle& hProv) at System.Security.Cryptography.Utils.AcquireProvHandle(CspParameters parameters) at System.Security.Cryptography
-
Error when trying impersonationAny help on this error?? This happens when I run the server with ID_A and try to run the client with ID_B .. this is an attempt to try impersonation System.TypeInitializationException was unhandled Message="The type initializer for 'System.Runtime.Remoting.Identity' threw an exception." Source="mscorlib" TypeName="System.Runtime.Remoting.Identity" StackTrace: Server stack trace: at System.Runtime.Remoting.Identity.RemoveAppNameOrAppGuidIfNecessary(String uri) at System.Runtime.Remoting.IdentityHolder.MakeURIKey(String uri) at System.Runtime.Remoting.IdentityHolder.ResolveIdentity(String URI) at System.Runtime.Remoting.RemotingServices.GetServerTypeForUri(String URI) at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at System.Object.FieldGetter(String typeName, String fieldName, Object& val) at ns_application.ns_client.cls_client.Main(String[] args) in D:\Vishwjeet\Study\Remoting_tcp\ConsoleApplication2\client.cs:line 64 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: System.Security.Cryptography.CryptographicException Message="Unknown error \"-2146893801\"." Source="mscorlib" StackTrace: at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr) at System.Security.Cryptography.Utils._AcquireCSP(CspParameters param, SafeProvHandle& hProv) at System.Security.Cryptography.Utils.AcquireProvHandle(CspParameters parameters) at System.Security.Cryptography.Utils.get_StaticProvHan
-
Error when trying impersonationThe code is working now .. but it works only for the account using which i have logged on onto the machine .. it says "The type initializer for 'System.Runtime.Remoting.Identity' threw an exception." when I give any other valid userid password
-
Error when trying impersonationHi.. I am trying impersonation in remoting .. it gives some error. The program runs fine when i turn off impersonation. I am running client and server both on the same machine(VISTA). Can anyone help me out find what am I doing wrong?? I have created the user account on the machine .. and it runs fine when i use secure channel and turn impersonation off.. I have also checked that when impersonation is off and using secure channel .. it allows only the users that i have created to logon .. otherwise it gives authentication failure. Following is the code : Server: using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using System.Collections; using System.Threading; using System.Security.Principal; namespace ns_application { namespace ns_server { public class cls_server { static void Main(string[] args) { //TcpChannel channel = new TcpChannel(8080); IDictionary props = (IDictionary) new Hashtable(); IPrincipal threadPrincipal; props.Add("port", "8080"); props.Add("secure", "true"); props.Add("impersonate", "true"); props.Add("protectionLevel", "EncryptAndSign"); //props.Add("username", "Vishwjeet"); //props.Add("password", "pwd"); //props.Add("authorizationModule", "AuthorizeUser"); //BinaryClientFormatterSinkProvider cp = new BinaryClientFormatterSinkProvider(); //BinaryServerFormatterSinkProvider sp = new BinaryServerFormatterSinkProvider(); IChannel chan = new TcpChannel(props,null,null); ChannelServices.RegisterChannel(chan,true); RemotingConfiguration.RegisterWellKnownServiceType(typeof(ns_registeruser.cls_registeruser), "ApplicationMain", WellKnownObjectMode.Singleton); threadPrincipal = Thread.CurrentPrincipal; Console.WriteLine(threadPrincipal.Identity.Name); Console.WriteLine(threadPrincipal.Identity.IsAuthenticated); Console.WriteLine(threadPrincipal.Identity.AuthenticationType); Console.WriteLine("Server Started .. "); Console.ReadLine(); } } } } Methods : using System; using System.Runtime.Serialization; using System.Reflection; using
-
Is this message board a correct place to ask remoting and webservices related doubts?Is this message board a correct place to ask remoting and webservices related doubts?:confused:
-
How to do this configuration programaticallyHere is a better link http://www.codeguru.com/columns/dotnet/article.php/c10253[^]
-
How to do this configuration programaticallyHi, I have aready seen this .. but didn't post it here.. thanks for doing it I got my answer on this link only. I am putting my code for others reference static void Main(string[] args) { //TcpChannel channel = new TcpChannel(8080); IDictionary props = (IDictionary) new Hashtable(); props.Add("port", "8080"); props.Add("secure", "true"); //props.Add("impersonate", "true"); //props.Add("authorizationModule", "AuthorizeUser"); BinaryClientFormatterSinkProvider cp = new BinaryClientFormatterSinkProvider(); BinaryServerFormatterSinkProvider sp = new BinaryServerFormatterSinkProvider(); IChannel chan = new TcpChannel(props,cp,sp); ChannelServices.RegisterChannel(chan,true); RemotingConfiguration.RegisterWellKnownServiceType(typeof(ns_registeruser.cls_registeruser), "ApplicationMain", WellKnownObjectMode.Singleton); Console.WriteLine("Server Started .. "); Console.ReadLine();
-
How to do this configuration programatically<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.runtime.remoting> <application name="AuthorizationApp"> <service> <wellknown mode="SingleCall" type="Server.SampleService, Server" objectUri="Server.rem"/> </service> <channels> <channel ref="tcp" port="8001" secure="true" impersonate="true" authorizationModule="Server.AuthorizationModule,Server"/> </channels> </application> </system.runtime.remoting> </configuration> how to set the properties "impersonation" and "authorizationModule" inside my program .. im not using the configuration files.
-
deploying server without visual studio and sql server -- only framework 3.5I would like to make one point clear .. Whenever my server is on vista machine ... nothing works ... but when i make my xp machine a server .. the same code works fine ... so this time .. im making my server on xp machine with .net fw installed .. but my sql server is on vista machine .. so i need to access this sql server through n/w as i cannot install sql server on my xp machine .. is my problem clear from this ..???:confused::confused:
-
deploying server without visual studio and sql server -- only framework 3.5probem is .. im not able to connect to my sql server from the oher machine .. how should i connect to the sql server instance working on my machine i.e.(A) from the other machine i.e.(B). I dont have sql server management studio on machine (B).
-
deploying server without visual studio and sql server -- only framework 3.5I am creating a simple remoting application which uses a strongly typed data set to retrieve data and send it to the cliet when required. This works fine when I have everything installed on my machine. Now I am trying to deploy the sever on a machine on my network ... but i have installed .net framework 3.5 on that machine ... no sql server or visual studio .. how can i make it work .. also, i tried to create an odbc for my sql server on the other machine .. but was unable to do that .. anyone any idea??
-
URI Format Not Supported. [modified]Well.. im not aware of what wcf supports .. but there must be some way to find the current directory's path
-
URI Format Not Supported. [modified]Dim client As New WebClient Dim strURL As String = "http://www.someurl.com/sendfile.php?file=myfile.gz" //Dim strFilename As String = Server.MapPath("myfile.gz") Dim strFilename As String = "c:\inetpub\wwwroot\my_app\images\myfile.gz" client.DownloadFile(strURL, strFilename)
i wanted to suggested this workaround .. as server.mappath is not working. -
URI Format Not Supported. [modified]server.mappath is being used to generate a local path(local to the server) .. u can use absolute path.
-
Help - RemotingYes it is .. unless there is a specific message board for .net remoting .
-
URI Format Not Supported. [modified]Hi, Have you tried this .. this is not my code .. I got it from net...
Dim client As New WebClient Dim strURL As String = "http://www.someurl.com/sendfile.php?file=myfile.gz" Dim strFilename As String = Server.MapPath("myfile.gz") client.DownloadFile(strURL, strFilename)
-
Help - RemotingHi.. I am using the following code for my remoting example. When I use MarshalByRefObject it works fine.
using System; namespace ns_application { namespace ns_authentication { public class cls_registeruser : MarshalByRefObject { private string _username; public cls_registeruser(string username) { _username = username; Console.WriteLine("Registered User :" + _username); } public cls_registeruser() { _username = "NULL"; Console.WriteLine("Username is " + _username); } ~cls_registeruser() { Console.WriteLine("User deleted" + _username); } public string username { get{return _username;} } } } }
But when I try to use [Serializable] it shows error "Trying to create a proxy to an unbound type".using System; namespace ns_application { namespace ns_authentication { [Serializable] public class cls_registeruser { private string _username; public cls_registeruser(string username) { _username = username; Console.WriteLine("Registered User :" + _username); } public cls_registeruser() { _username = "NULL"; Console.WriteLine("Username is " + _username); } ~cls_registeruser() { Console.WriteLine("User deleted" + _username); } public string username { get{return _username;} } } } }
As far as I know : "MarshalByRefObject" will give me a reference to an object created on the server. All the execution will take place on the server. "Serializable" will send to me the object state, and the execution will be done at the client machine itself. But at some places I see the following usage :[Serializable] public class_name : MarshalByRefObject
What does this mean? Also, if [Serializable] is there, what is the use of "ISerializable" interface. Waiting for responses guyz... I have googled a lot already but am not getting a clear picture. -
Explanation neededwe bind custom built assemblies .. depending on the version of the framework or the processorarchitecture these are not custom built assemblies they are system assemblies.. and only these two are binded ... is this not required for other system assemblies??? i have taken this from an auto generated web.config