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

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

authentication on NTLM Proxy

How to authenticate on NTLM proxy server from my application.
I have no idea how to do this, I have found a broken link here about this subject, anyone can help me ?
I need to know how NTLM proxy works
what components or objects C++ builder 6 have to dealing with this.
A good example is apreciated and links to this subject too.

best regards
0
directcall
Asked:
directcall
  • 2
1 Solution
 
CayceCommented:
Can you elaborate your question?

Thanks
0
 
directcallAuthor Commented:
Well,

I trying to access a web page from my bcb6 application, but I have had dificult with NTLM proxy-authentication because I dont Know how it works. I need a component that do this authentication for me, I know indy components but I think it do only basic authentication or not ? Links to this subject and code examples are apreciated too.

Thanks
0
 
CayceCommented:
This article explains how to do it using the TNMHTTP component: http://www.delphi3000.com/articles/article_1434.asp?SK=

It's on delphi, but changing it to pascal should be not hard at all.

As a matter of fact here's it:

AnsiString __fastcall EncodeAuth(AnsiString username, AnsiString password)
{
  TNMUUProcessor *uu;
  TStringStream *si, *so;
  AnsiString decoded;
  AnsiString encoded;
  AnsiString result;

  decoded = username+":"+password; // Username:Password
  encoded.SetLength(20 * decoded.Length()); // Estimate len

  uu = new TNMUUProcessor(Application); // UU Processor
  si = new TStringStream(decoded); // Input
  so = new TStringStream(encoded); // Output

  uu->InputStream = si;
  uu->OutputStream = so;
  uu->Method = uuMime;
  uu->Encode(); // Decode

  result = so->ReadString(255); // Read Result
  result = result.SubString(1, result.Pos("\n") - 1); // No CRLF

  delete si;
  delete so;
  delete uu;

  return result;
}

void __fastcall TForm1::NMHTTP1AboutToSend(TObject *Sender)
{
  String username;
  String password;
  // username and password should be defined somewhere else
  NMHTTP1->SendHeader->Insert(2, "Proxy-authorization: " + EncodeAuth(username, password));
}
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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