Forcing EM users to log out v4.1.3

Unanswered Question
Feb 18th, 2007

What is the best way to log out all users from EM?

This is required to update devices which cannot be done when users are logged in.

I have tried setting the forced logout after 5 mins, but this wont work if users are already logged in.

I have this problem too.
0 votes
  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
Loading.

select name from device where loginTime > '0'

copy the MACs to a file

replace x.x.x.x with the IP of your Publisher

use AXL Browser(in the SDK) to to connect to your publisher, turn on Full Soap Logging. Get Person or whatever - you just need to make a SOAP request. Look in the logging window and cut the password - QWQDF1231AAF~! and paste it after Basic (overwrite "base64Password")

save file

run perl filename

#!perl

use CGI;

use LWP::UserAgent;

use HTTP::Request::Common;

use HTTP::Headers;

use SOAP::Lite;

use IO::File;

my $deviceName;

my $axlRequest;

my $file="testOut.csv";

my $axlType;

my $host;

my $soapHeader;

my $soapFooter;

open (LOGIN,$file) or die print "$file could not be opened $!";

$axlType="doDeviceLogout";

$host = 'x.x.x.x:80';

$soapHeader="http://schemas.xmlsoap.org/soap/envelope/\"

xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"

xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">

";

$soapFooter=" ";

while (){

my $data=$_;

my @line = split(/,/,$data);

chomp @line;

foreach ($data){

$deviceName="".$line[0]."" ;

&axlSend;

}

}

sub axlSend{

$axlRequest="http://www.cisco.com/AXL/1.0\" xsi:schemaLocation=\"http://www.cisco.com/AXL/1.0 http://gkar.cisco.com/schema/axlsoap.xsd\" sequence=\"10\">

$deviceName

";

my $userAgent = LWP::UserAgent->new(agent => 'POST doDeviceLogout');

my $request="$soapHeader $axlRequest $soapFooter";

my $response = $userAgent->request(POST 'http://x.x.x.x/CCMApi/AXL/V1/soapisapi.dll',

Content_Type => 'text/xml',

Host => $host,

Authorization => 'Basic base64Password',

Content => $request);

#&html_header;

print $response->error_as_HTML unless $response->is_success;

$error=$response->as_string;

if (!$response->is_success){

print "Could not open connection to $host, $deviceName not logged off!";

}

elsif ($error=$response->as_string){

if ($error =~ /fault/){

print $response->error_as_HTML;

}

else { print "RESULT: logged out of $deviceName\n";

sleep(3);

}

}

}

&close_file;

#&html_footer;

sub html_header {

print "Content-type: text/html\n\n";

print "Lab CM\n";

print "

\n";

}

sub html_footer {

print "

"

}

sub close_file{

close(LOGIN);

}

If you run

select name, ikCurrentDeviceProfile, loginuserid from device where loginTime > '0'

put this in an excel spreadsheet - insert a new column after column 1 make the value 0 for all rows - save as .csv and this perl code will re-login all of your users.

Again, do not remove the sleep statement or run during production.

#!perl

## Author: Chris Harris

## Company: eLoyalty Corporation

use CGI;

use LWP::UserAgent;

use HTTP::Request::Common;

use HTTP::Headers;

use SOAP::Lite;

use IO::File;

my $deviceName;

my $loginDuration;

my $profileID;

my $loginID;

my $axlRequest;

my $file="testOut.csv";

my $axlType;

my $host;

my $soapHeader;

my $soapFooter;

open (LOGIN,$file) or die print "$file could not be opened : $!";

$axlType="doDeviceLogin";

$host = 'x.x.x.x:80';

$soapHeader="http://schemas.xmlsoap.org/soap/envelope/\"

xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"

xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">

";

$soapFooter=" ";

while (){

my $data=$_;

my @line = split(/,/,$data);

chomp @line;

foreach ($data){

if ($line[0] =~ m/^SEP[a-z0-9](.+)/i && length $1=='12'){

$deviceName="".$line[0]."" ;

$loginDuration="".$line[1]."" ;

$profileID="".$line[2]."" ;

$loginID="".$line[3]."" ;

&axlSend;

}

else {print "$line[0] in Field 1 does not appear to contain a valid IP Phone MAC Address. Should be SEP + 12 digits" ; exit 0;}

}

}

sub axlSend{

$axlRequest="http://www.cisco.com/AXL/1.0\" xsi:schemaLocation=\"http://www.cisco.com/AXL/1.0 http://gkar.cisco.com/schema/axlsoap.xsd\" sequence=\"10\">

$deviceName

$loginDuration

$profileID

$loginID

";

my $userAgent = LWP::UserAgent->new(agent => 'doDeviceLogin');

my $request="$soapHeader $axlRequest $soapFooter";

## Use AXL Browser in IP Phone SDK with Full Soap logging to obtain Autorization String

my $response = $userAgent->request(POST 'http://x.x.x.x/CCMApi/AXL/V1/soapisapi.dll',

Content_Type => 'text/xml',

Host => $host,

Authorization => 'Basic base64Password',

Content => $request);

print $response->error_as_HTML unless $response->is_success;

$error=$response->as_string;

if (!$response->is_success){

print "Could not open connection to $host, $deviceName not logged off!";

}

elsif ($error=$response->as_string){

if ($error =~ /fault/){

print $response->error_as_HTML;

}

else { print "RESULT: $loginID logged into $deviceName\n";

sleep(3);

}

}

}

&close_file;

sub close_file{

close(LOGIN);

}

Actions

This Discussion