Click here to Skip to main content
15,895,667 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionWebservice multiple calls Pin
Matt Cavanagh20-Sep-09 13:08
Matt Cavanagh20-Sep-09 13:08 
AnswerRe: Webservice multiple calls Pin
Christian Graus20-Sep-09 13:59
protectorChristian Graus20-Sep-09 13:59 
GeneralRe: Webservice multiple calls Pin
Matt Cavanagh20-Sep-09 20:55
Matt Cavanagh20-Sep-09 20:55 
QuestionImpersonation throwing exception Pin
vishwjeet20-Sep-09 6:19
vishwjeet20-Sep-09 6:19 
AnswerRe: Impersonation throwing exception Pin
Abhishek Sur20-Sep-09 7:59
professionalAbhishek Sur20-Sep-09 7:59 
GeneralRe: Impersonation throwing exception Pin
vishwjeet20-Sep-09 8:23
vishwjeet20-Sep-09 8:23 
GeneralRe: Impersonation throwing exception Pin
Abhishek Sur20-Sep-09 10:25
professionalAbhishek Sur20-Sep-09 10:25 
GeneralRe: Impersonation throwing exception Pin
vishwjeet20-Sep-09 11:33
vishwjeet20-Sep-09 11:33 
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_whereitruns(int IDNo)
{
this.IDNo = IDNo;
Console.WriteLine("Created ID : {0} :::: {1} :::: {2}", IDNo, this.ToString(), AppDomain.CurrentDomain.FriendlyName);
}

public DataTable RMS_DIV_Data()
{
//OleDbDataAdapter dataAdapter = new TempDataSet.
TempDataSetTableAdapters.DIV60 da = new ns_application.TempDataSetTableAdapters.DIV60();
TempDataSet.__TKOCLIENT_DIV160DataTable internalTable = new TempDataSet.__TKOCLIENT_DIV160DataTable();
da.Fill(internalTable);
Console.WriteLine("Methods Connection String :: " + System.Configuration.ConfigurationManager.ConnectionStrings["ns_application.Properties.Settings.RetentionManagementSystemConnectionString"]);
Console.WriteLine(internalTable[0][0]);
return internalTable;
}
}

//public class cls_registeruser
public class cls_registeruser : MarshalByRefObject
{
public cls_whereitruns _obj = new cls_whereitruns(5);
private string _username;

public string username
{
get { return _username; }
}
public cls_registeruser()
{
_username = "Blank";

IPrincipal threadPrincipal = Thread.CurrentPrincipal;
Console.WriteLine(threadPrincipal.Identity.Name);
Console.WriteLine(threadPrincipal.Identity.IsAuthenticated);
Console.WriteLine(threadPrincipal.Identity.AuthenticationType);

Console.WriteLine("Registered User " + username);
}
public cls_registeruser(string username)
{
_username = username;
Console.WriteLine("Registered User " + username);
}
~cls_registeruser()
{
Console.WriteLine("Destructor called");
}
}
}
}

Client:
#define VISTA
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Collections;

namespace ns_application
{
namespace ns_client
{
public class cls_client
{
static void Main(string[] args)
{
IChannel channel = new TcpChannel();
ChannelServices.RegisterChannel(channel,true);
//try
//{
#if VISTA
ns_registeruser.cls_registeruser user_obj = (ns_registeruser.cls_registeruser)Activator.GetObject(typeof(ns_registeruser.cls_registeruser), "tcp://kk-pc:8080/ApplicationMain");
#else
ns_registeruser.cls_registeruser user_obj = (ns_registeruser.cls_registeruser)Activator.GetObject(typeof(ns_registeruser.cls_registeruser), "tcp://everest:8080/ApplicationMain");
#endif
IDictionary props = ChannelServices.GetChannelSinkProperties(user_obj);
//props["domain"] = "WORKGROUP11";
#if VISTA
props["tokenImpersonationLevel"] = "identification";
props["username"] = "Vishwjeet";
props["password"] = "pwd";
props["secure"] = "true";
props["protectionLevel"] = "EncryptAndSign";
Console.WriteLine(props["username"]);

#else
props["username"] = "something";
Console.WriteLine(props["username"]);
props["password"] = "hello";
#endif
Console.WriteLine("Till 1");

Console.WriteLine(user_obj._obj.FutureofID());
Console.WriteLine("Till 2");
Console.WriteLine(user_obj._obj.FutureofID());
user_obj._obj.IDNo = 35;
//Console.WriteLine("Client Connection String :: " + System.Configuration.ConfigurationManager.ConnectionStrings["ns_application.Properties.Settings.RetentionManagementSystemConnectionString"]);
Console.WriteLine(user_obj._obj.FutureofID());
Console.WriteLine(user_obj._obj.IDNo);
//Console.WriteLine(user_obj._obj.RMS_DIV_Data());
Console.WriteLine("Client Object Created for user . ." + user_obj.username);
//}
//catch (Exception e)
//{
// Console.WriteLine(e.ToString());
//}
Console.ReadLine();
}
}
}
}
GeneralCookie is not working in IIS 6.0 Pin
prasannadotnet20-Sep-09 6:06
prasannadotnet20-Sep-09 6:06 
QuestionHow to detect the user IP? Pin
Seraph_summer20-Sep-09 4:28
Seraph_summer20-Sep-09 4:28 
AnswerRe: How to detect the user IP? Pin
Parwej Ahamad20-Sep-09 4:40
professionalParwej Ahamad20-Sep-09 4:40 
GeneralRe: How to detect the user IP? Pin
amitraj8220-Sep-09 5:15
amitraj8220-Sep-09 5:15 
GeneralRe: How to detect the user IP? Pin
Seraph_summer20-Sep-09 5:17
Seraph_summer20-Sep-09 5:17 
GeneralRe: How to detect the user IP? Pin
Parwej Ahamad20-Sep-09 5:20
professionalParwej Ahamad20-Sep-09 5:20 
GeneralRe: How to detect the user IP? Pin
Seraph_summer20-Sep-09 5:23
Seraph_summer20-Sep-09 5:23 
GeneralRe: How to detect the user IP? Pin
Parwej Ahamad20-Sep-09 5:27
professionalParwej Ahamad20-Sep-09 5:27 
GeneralRe: How to detect the user IP? Pin
Seraph_summer20-Sep-09 5:30
Seraph_summer20-Sep-09 5:30 
GeneralRe: How to detect the user IP? Pin
Parwej Ahamad20-Sep-09 5:32
professionalParwej Ahamad20-Sep-09 5:32 
NewsRe: How to detect the user IP? Pin
Abhishek Sur20-Sep-09 5:31
professionalAbhishek Sur20-Sep-09 5:31 
AnswerRe: How to detect the user IP? Pin
Abhishek Sur20-Sep-09 4:42
professionalAbhishek Sur20-Sep-09 4:42 
GeneralRe: How to detect the user IP? Pin
Seraph_summer20-Sep-09 5:04
Seraph_summer20-Sep-09 5:04 
GeneralRe: How to detect the user IP? Pin
Abhishek Sur20-Sep-09 5:24
professionalAbhishek Sur20-Sep-09 5:24 
GeneralRe: How to detect the user IP? Pin
Seraph_summer20-Sep-09 5:28
Seraph_summer20-Sep-09 5:28 
GeneralRe: How to detect the user IP? Pin
ABitSmart20-Sep-09 15:40
ABitSmart20-Sep-09 15:40 
QuestionASP.NET Login Name Problem Pin
morteza45120-Sep-09 1:50
morteza45120-Sep-09 1:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.