Hi bitmuncher,
Hier ist dann mal das Skript, habe deswegen Curl genommen weil ich einfach nur das PHP-Skript von Scott Milliken umgeschrieben habe.
#!/usr/bin/perl
#use strict;
use warnings;
use WWW::Curl::Easy;
if (@ARGV < 3) {
print "Zu wenig Parameter!";
exit 3;
}
# OWA Login Check
# Written by Scott Milliken in PHP rewritten by Thomas Bruckmann in Perl
# Modified by Chris Funderburg for Exchange 2007 - May 21, 2010
# Permission granted to use under the GPL
my $hostaddress = $ARGV[0];
my $username = $ARGV[1];
my $password = $ARGV[2];
# You can just use the base URL for your default mailbox
# or you can add on to it to specify a group mailbox
# $mailboxURL = "https://email.mydomain.com" for default
# or for a shared NOC mailbox in the IT department...
my $mailboxURL = "https://$hostaddress/owa/";
my $authURL = "https://$hostaddress/owa/auth/logon.aspx?url=https://$hostaddress/owa/&reason=0";
# First go to the URL that a user would use so that you can get your session cookie set
my $curl = new WWW::Curl::Easy;
$curl->setopt(CURLOPT_URL, $mailboxURL);
$curl->setopt(CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)");
$curl->setopt(CURLOPT_FOLLOWLOCATION, '1');
# You need to define a cookie jar to store and retrieve
# the session cookies or this won't work
$curl->setopt(CURLOPT_COOKIEJAR, "cookies.txt");
$curl->setopt(CURLOPT_COOKIEFILE, "cookies.txt");
#url_setopt( $pg, CURLOPT_COOKIEFILE, "cookies.txt" );
$curl->setopt(CURLOPT_HEADER, '0');
#$curl->setopt(CURLOPT_RETURNTRANSFER, 0);
# Setting these to false is handy for checking multiple
# frontends that may share the same SSL cert, such as
# ones in a round robin DNS scheme, but you address
# them by the "real name" of the host
$curl->setopt(CURLOPT_SSL_VERIFYPEER, '0');
$curl->setopt(CURLOPT_SSL_VERIFYHOST, '0');
# Set this to true for debugging
$curl->setopt(CURLOPT_VERBOSE, '0');
my $response;
open (FILE, ">/dev/null");
$curl->setopt(CURLOPT_WRITEDATA,0);
$curl->setopt(CURLOPT_FILE,\*FILE);
my $err = $curl->errbuf;
$curl->perform();
my $info = $curl->getinfo(CURLINFO_HTTP_CODE);
print "\n########################\n";
if ($info ne "200") {
print "Critical - OWA ist nicht erreichbar!\n";
exit 2;
}
# Set the form data for posting the login information
my %postData = ();
$postData{'url'} = $mailboxURL;
$postData{'reason'} = '0';
$postData{'destination'} = $mailboxURL;
$postData{'flags'} = '0';
$postData{'username'} = $username;
$postData{'password'} = $password;
$postData{'SubmitCreds'} = 'Log On';
my $postText = "";
for my $key (keys %postData) {
$postText .= $key . "=" . $postData{$key} . "&";
}
$curl->setopt(CURLOPT_REFERER, $curl->getinfo(CURLINFO_EFFECTIVE_URL));
$curl->setopt(CURLOPT_URL, $authURL);
$curl->setopt(CURLOPT_POST, '1');
$curl->setopt(CURLOPT_POSTFIELDS, $postText);
$curl->perform;
# At this point you can either print the following
# status to show the result of logging in, or you
# can make another call to the web server for the
# individual frames, such as
# $mailboxURL . "/Inbox/?Cmd=contents" will give you
# the listing of inbox headers (if you call curl again)
$info = $curl->getinfo(CURLINFO_HTTP_CODE);
if ($info ne "200") {
print("Critical - OWA-Login mit User $username Fehlgeschlagen!\n");
exit 2;
}
print("OK - OWA-Login mit User $username erfolgreich!\n");
exit 0;