-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsuser.pl
executable file
·66 lines (52 loc) · 1.37 KB
/
msuser.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#! /usr/bin/perl
use strict;
use warnings;
use v5.10;
use Data::Dumper;
use Config::Simple;
use FindBin;
use POSIX qw(strftime);
use Getopt::Long;
use lib "$FindBin::Bin/lib";
use MsUser;
use Logger;
my %config;
Config::Simple->import_from("$FindBin::Bin/groups.cfg",\%config) or die("No config: $!");
my $now = time();
my $ts = strftime('%Y-%m-%dT%H:%M:%S', localtime($now));
my $user;
my $verbose;
GetOptions(
"user=s" => \$user,
"verbose" => \$verbose,
) or die("Error in command line options: $!");
# Start of the logger
my $logger = Logger->new(
'filename' => "$FindBin::Bin/Log/$FindBin::Script-$ts.log",
'verbose' => $verbose
);
$logger->make_log("$FindBin::Bin/$FindBin::Script started.");
if (@ARGV){
$logger->make_log("ARGV is: ");
}else{
$logger->make_log("No commandline options");
}
if ($verbose){
$logger->make_log("Verbose is set.");
}
my $session = MsUser->new(
'app_id' => $config{'APP_ID'},
'app_secret' => $config{'APP_SECRET'},
'tenant_id' => $config{'TENANT_ID'},
'login_endpoint' => $config{'LOGIN_ENDPOINT'},
'graph_endpoint' => $config{'GRAPH_ENDPOINT'},
'user' => $user,
);
if ($session->_get_access_token){
my $UserInfo = $session->fetch_user();
$logger->make_log("$user fetched.");
$logger->make_log("userPrincipalName: ".$UserInfo->{'userPrincipalName'});
}else{
print "No token!\n";
}
# vim: set foldmethod=marker