[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

ident server

i need to know how to connect to an ident server and get a username. Any help would be appreciated.

Thank you
0
GoRgOn
Asked:
GoRgOn
  • 2
1 Solution
 
ptmcompCommented:
0
 
GoRgOnAuthor Commented:
ive already looked at that. i need to know how to connect to an ident server from C# and the retrieve a username.
0
 
ptmcompCommented:
string GetIdent(int serverPort, int clientPort)
{
    const string identServerAddr = "192.168.0.1"; // replace with the ip of the ident server

    string returndata = null;

    TcpClient tcpClient = new TcpClient();
    try{
        tcpClient.Connect(identServerAddr, 113);
        NetworkStream networkStream = tcpClient.GetStream();

        if(networkStream.CanWrite && networkStream.CanRead){

            string request;
            request = string.Format("{0}, {1}\r\n", serverPort, clientPort)          
            Byte[] sendBytes = Encoding.ASCII.GetBytes();
            networkStream.Write(sendBytes, 0, sendBytes.Length);
     
            byte[] bytes = new byte[tcpClient.ReceiveBufferSize];
            networkStream.Read(bytes, 0, (int) tcpClient.ReceiveBufferSize);
 
           returndata = Encoding.ASCII.GetString(bytes);
           tcpClient.Close();
          }
       }
       catch (Exception e ) {
                  Console.WriteLine(e.ToString());
    }
    return returndata;
}

I don't have an ident server running, so i didn't test it.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now