Sockects with authentication

G

Guest

Hi
I want to create a socket using C# to connect to a proxy server which is password authenticated. So how do I pass the username and password to connect to the server
I am using System.Net.Sockets.Socket class for connection

Thanks in Advance

Regards
Manish.
 
F

Feroze [MSFT]

Is it an HTTP proxy server ? If so, the answer depends on the type of
authentication method requested by the server.

If you want to do HTTP through an authenticated proxy, you should be using
System.Net.HttpWebRequest. It handles proxy and server authentication. You
just need to provide credentials.

--
Remove "user" from the email address to reply to the author.

This posting is provided "AS IS" with no warranties, and confers no rights

Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm




Manish Buttan said:
Hi,
I want to create a socket using C# to connect to a proxy server which
is password authenticated. So how do I pass the username and password to
connect to the server.
 
G

Guest

Hi Feroze
I want to connect to my FTP Server through the authenticated proxy server. My application works behind the proxy when there is no authentication enabled at the proxy server. I am unable to pass the authentication to the socket once the proxy server is authenticated.
So can you please help me as how to pass the username/pasword to get connected to the proxy server through sockets

Regards
Manish.
 
T

Tian Min Huang

Hi Manish,

Could you please tell me what type of proxy you are using?

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
G

Guest

Hi HuangTM
I have a eval version of CCProxy as a proxy server installed.

My core problem is :

How to create a socket to connect to this proxy server when the proxy server is set for authentication
The problem is the Socket class of .NET does not provide me any methods or properties to be set for authentication

Regards
Manish.
 
T

Tian Min Huang

Hello Manish,

In .NET, I suggest that you can use WebRequest and its derived class which
supports proxy to communicate to your FTP server. also take a look on the
www.gotdotnet.com site.

There is a sample at
http://www.gotdotnet.com/userfiles/Feroze/ftpclient.zip which provdes a FTP
client class derived from WebRequest and supports Proxy. Please take a look
at it.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
T

Tian Min Huang

Hello Manish,

I wanted to post a quick note to see if you would like additional
assistance or information regarding this particular issue. We appreciate
your patience and look forward to hearing from you!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
G

Guest

Hi HuangTM
Thanks for the link that you have sent regarding the sample code.
I tried to run the code behind the proxy server with the following command line arguments

-uftp://64.235.50.69 -pntserver:2121 -v -kutest:proxy -kptestuser:tes
1. ftp://64.235.50.69 is my ftp server
2. ntserver is my proxy server
3. 2121 is the port mapped at my proxy server for FTP
4. "test" is my ftp server's username
5. "proxy" is the password of the ftp server
6. "testuser" is the username of the proxy server to connect to
7. "test" is the password to connect to proxy server

I am not able to connect still to my FTP Server with the above arguments
Some times the application hangs or else I get the error message saying "Couldnt open passive data connection. FTP protocol Error..... Status:500 Description:must be connected to remote server."
I also tried to look into the code but was not clear with code to establish the connection to the proxy Server
Can you please help me out as to where the username/password of the proxy is passed to the socket while connecting to the proxy Server. Also please can you explain me what the "ServicePointManager.FindServicePoint" method does. I tried to read this documentation in MSDN but was not clear with the same

Thanks and Regards
Manish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top