Feneden has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Authorizing with NTLM - Problem Domain
by soonix (Chancellor) on May 19, 2018 at 12:01 UTC | |
|
Re: Authorizing with NTLM - Problem Domain
by Anonymous Monk on May 18, 2018 at 06:41 UTC | |
by Feneden (Acolyte) on May 18, 2018 at 08:39 UTC | |
by haukex (Archbishop) on May 18, 2018 at 08:47 UTC | |
by Feneden (Acolyte) on May 18, 2018 at 08:52 UTC | |
by haukex (Archbishop) on May 18, 2018 at 08:58 UTC |