Hi there,

I asked a rather similar question some time ago. On the former post I found a solution. Now I want to use a different user. The problem is: -> The user is from a different domain: itīs not like MyCompanyNameDE\username instead itīs like MyCompanyNameCOM\username.

When I use a username which is on the MyCompanyNameDE domain, I just can insert the raw username into the "user" field.

Here is the code I am using to play the challenge-response game with the server:

my $Options = { user => 'UsernameIsHere', password => "***********", domain => 'ServerAddressIsHere.com/', timeout => 30, protocol => "https", AuthMethod => "NTLM", ##BrowserAgent => "MSIE 6.0; Windows NT 5.0", RequestMethod => "GET", ##DataDir => "/tmp", }; ##my $log = "/var/tmp/get_url.log"; ##my $DataDir = "/tmp"; my $ua = LWP::UserAgent->new(keep_alive=>'1'); ##agent=>'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)', ###################################### # First stage of NTLM authentication # ###################################### my $url = "http://ServerAddressIsHere.com/mbSDKService/MsgSDK.asmx/Run +Query?queryName=QueryNameIsHere"; ntlm_domain($Options->{'domain'}); ntlm_user($Options->{'user'}); ntlm_password($Options->{'password'}); my $Authorization = Authen::NTLM::ntlm(); my $header = HTTP::Headers->new( ##Content_Type => 'text/html', ##'WWW-Authenticate' => $Options->{'AuthMethod'} ); $header->header('Authorization' => "NTLM $Authorization"); my $request = HTTP::Request->new($Options->{'RequestMethod'} => $url, +$header); my $res = $ua->request( $request ); ################################## # Second stage of authentication # ################################### ### challenge my $Challenge = $res->header('WWW-Authenticate'); $Challenge =~ s/^NTLM //g; $Authorization = Authen::NTLM::ntlm($Challenge); $header->header('Authorization' => "NTLM $Authorization"); $request = HTTP::Request->new($Options->{'RequestMethod'} => $url, $he +ader); $res = $ua->request( $request ); ### ntlm reset for eventual connects with a different user #ntlm_reset(); if($res->is_success) { $data = $res->decoded_content(); } else { print "ERROR: Can not dump data from $url\nReturned code: " . $res +->code . " (" . $res->status_line . ")\n"; exit; }

All in all this request is about obtaining an XML from a web service.

Thanks in advance! Regards Feneden

In reply to Authorizing with NTLM - Problem Domain by Feneden

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.