Thought I'd make use of the expiry feature that still hasn't changed (after all these years) by running a chore.
Idea is to record a copy of the 'PasswordLastTimeUpdated' in a new }Client attribute then compare date-time differences to see
1. If user has changed password (time-stamp variance)
2. Days passed since password was set (Now - 'PasswordLastTimeUpdated')
and delete the Client's expiry if the password was changed so it doesn't lock them out or continue to nag them.
Code: Select all
tm1server:}Clients->All
#(Prolog)
# ////////////////////////////////////////////////////////////////////////////////////////////////////////
# This process is designed to scan all Clients and check for 'InitPasswordTime' attribute [created by admin]
# and execute the data tab section otherwise skip Client.
# the Client's 'InitPasswordTime' attribute MUST be the same date-time as 'PasswordLastTimeUpdated'
# in }ClientProperties at the time when their initial "temporary" password was set when new user was
# created
# }ElementAttributes_}Clients
# - FirstName, EmailAddr
# }ClientProperties
# - PasswordLastTimeUpdated
# - PasswordExpirationDays
# - [ check SecurityAdmin access is ticked for this process eg: as chore ]
# ////////////////////////////////////////////////////////////////////////////////////////////////////////
FilePath = 'E:\Cognos\TM1\Custom\TM1Data\tm1server\TM1LogFiles\output_text\';
# FilePath = '\\105.127.127.01\cognos\tm1\custom\tm1data\tm1server\TM1LogFiles\output_text\';
FileName = GetProcessName();
# Get today's date in YYYYMMDD format
pwdNow = StringToNumber('20' | SUBST(Date(NOW) ,1, 2) | SUBST(Date(NOW) ,4, 2) | SUBST(Date(NOW) ,7, 2));
# Get today's date in YYYY-MM-DD format for use with DayNo
pwdNowS = '20' | SUBST(Date(NOW) ,1, 10);
# Email - Static SendEMail.exe parameters
# no '-' in CmdStr message, get's mixed with switches
aFilePath = '\\105.127.127.01\cognos\tm1\custom\tm1data\tm1server\tm1inputfiles\sendemail.exe';
aFrom = '-f tm1admin@mycompany.com';
aSubject = '-u TM1 Password Alert !';
aMailServer = '-s vesvexms02.mycompany.com';
vLastName = '';
vCount = 0;
xCount = 0;
recCount = 0;
# get pwd update time when 'Secu_Client Pwd.pro' was last run
# pwdControlS = CellGetS('lu_control', 'Password_Control', 'measure');
# **(Mod) initial password update time stored as client attribute for this process
#(Data)
# //////////////////////////////////////////////////////////////////////////////////////////
# Calc number of days since last pwd change;
# if >= x days, (@day 4)
# - get user email, name and send message if email attr exists
# if pwd changed before expiry
# - remove pwd expiry days & clear pwd time logged
#//////////////////////////////////////////////////////////////////////////////////////////
# **(Mod) ************************************************************
pwdControlS = Attrs('}Clients', vClient, 'InitPasswordTime');
# *new Get expiry days and check against pwd time if manual override occured
pwdDayS = CellGetS('}ClientProperties', vClient, 'PasswordExpirationDays');
If (pwdControlS @= '');
ItemSkip;
ElseIf (pwdControlS @<> '' & pwdDayS @= '');
AttrPutS(pwdControlS, '}Clients', vClient, 'Overridden');
AttrPutS('', '}Clients', vClient, 'InitPasswordTime');
vFirstName = AttrS('}Clients', vClient, 'FirstName');
vLastName = AttrS('}Clients', vClient, 'LastName');
ASCIIOutput(FilePath | FileName | '.txt', ' ------------', 'Pwd expiry cleared MANUALLY:= ' | vClient, vFirstName | ' ' | vLastName);
# admin email if anything recoreded in text attachment
recCount = recCount + 1;
ItemSkip;
EndIf;
# **(Mod) ************************************************************
vEmail = '';
vFirstName = '';
CmdStr = '';
pwdTimeFullS = CellGetS('}ClientProperties', vClient, 'PasswordLastTimeUpdated');
# Changed the if else sequence to check for pwd change 1st then check days passed afterwards
pwdTimeS = Subst(CellGetS('}ClientProperties', vClient, 'PasswordLastTimeUpdated'), 1, 8);
# Change format to YYYY-MM-DD
pwdTimeS = SubSt(pwdTimeS, 1, 4) | '-' | SubSt(pwdTimeS, 5, 2) | '-' | SubSt(pwdTimeS, 7, 2);
pwdLapseN = DayNo(pwdNowS) - DayNo(pwdTimeS);
pwdLapseS = NumberToString(pwdLapseN);
vEmail = AttrS('}Clients', vClient, 'EmailAddr');
vFirstName = AttrS('}Clients', vClient, 'FirstName');
vLastName = AttrS('}Clients', vClient, 'LastName');
aTo1 = '-t ' | vEmail;
# 100 ~ about 1 minute
If (StringToNumber(pwdTimeFullS) - StringToNumber(pwdControlS) > 100);
# Remove Password Expiry
If (CellgetS('}ClientProperties', vClient, 'PasswordExpirationDays') @<> '');
CellputS('', '}ClientProperties', vClient, 'PasswordExpirationDays');
# **(Mod) ************************************************************
AttrPutS('', '}Clients', vClient, 'InitPasswordTime');
# **(Mod) ************************************************************
ASCIIOutput(FilePath | FileName | '.txt', ' ------------', 'Pwd expiry cleared:= ' | vClient, 'Pwd Day:= ' | pwdTimeS);
xCount = xCount + 1;
EndIf;
Else;
# Pwd not changed
ASCIIOutput(FilePath | FileName | '.txt', 'Pwd Lapse:= ' | pwdLapseS, 'Client:= ' | vClient, 'Email:= ' | vEmail, 'Name:= ' | vFirstName, 'Pwd Day
:= ' | pwdTimeS);
If (vEmail @<>'');
If (pwdLapseN = 4);
# Pwd not changed AND 4 days gone since pwd was updated and/or initial password given out, and Has email, construct message body
If (Trim(vFirstName) @='');
aBody = '-m Please change your password TODAY. if your login [' | vClient | '] is deactivated tomorrow, contact your TM1 Administrator
';
Else;
aBody = '-m Dear ' | vFirstName | ', please change your password TODAY, if your login [' | vClient | '] is deactivated tomorrow, conta
ct your TM1 Administrator';
EndIf;
CmdStr = aFilePath | ' ' | aFrom | ' ' | aTo1 | ' ' | aSubject | ' ' | aBody | ' ' | aMailServer;
#!** ExecuteCommand (CmdStr , 1);
ExecuteCommand (CmdStr , 1);
ASCIIOutput(FilePath | FileName | '.txt', ' ----------->', 'Email sent to:= ' | vClient);
ElseIf(pwdLapseN > 4 & pwdLapseN <= 11);
# Pwd not changed AND therefore expired and user can't use pwd to login anymore, construct different message
If (Trim(vFirstName) @='');
aBody = '-m If your login [' | vClient | '] has deactivated, contact your TM1 Administrator';
Else;
aBody = '-m Dear ' | vFirstName | ', If your login [' | vClient | '] has deactivated, contact your TM1 Administrator';
EndIf;
CmdStr = aFilePath | ' ' | aFrom | ' ' | aTo1 | ' ' | aSubject | ' ' | aBody | ' ' | aMailServer;
#!** ExecuteCommand (CmdStr , 1);
ExecuteCommand (CmdStr , 1);
ASCIIOutput(FilePath | FileName | '.txt', ' ----------->', 'Email sent to:= ' | vClient);
# Stop sending reminder
ElseIf(pwdLapseN > 11);
ASCIIOutput(FilePath | FileName | '.txt', ' -----------X', 'Email NOT sent to:= ' | vClient);
Else;
# Pwd not changed AND < 4 days before email alert
# Emails are going out
If (Trim(vFirstName) @='');
aBody = '-m Please change your password, otherwise your login [' | vClient | '] will expire soon';
Else;
aBody = '-m Dear ' | vFirstName | ', please change your password, otherwise your login [' | vClient | '] will expire soon';
EndIf;
CmdStr = aFilePath | ' ' | aFrom | ' ' | aTo1 | ' ' | aSubject | ' ' | aBody | ' ' | aMailServer;
#!** ExecuteCommand (CmdStr , 1);
ExecuteCommand (CmdStr , 1);
ASCIIOutput(FilePath | FileName | '.txt', ' ---------->>', 'Email sent to:= ' | vClient);
EndIf;
Else;
# Has NO Email
ASCIIOutput(FilePath | FileName | '.txt', ' >>>>>>>>>>>>', 'No Email Attr Found for User:= ' | vClient, vFirstName | ' ' | vLastName);
EndIf;
# tmp - live emails used
# ASCIIOutput(FilePath | FileName | '.txt', 'CmdStr:= ' | CmdStr);
vCount = vCount + 1;
EndIf;
recCount = recCount + 1;
#(Epilog)
# Send Output Log as attachment
# ' 0 ' with a leading space causes switch in cmdstr to fail, so joined with ':=' no spaces
# if any pwdtime is currently recoreded in }Clients attribute. ie: password assigned with expiry recently
If (recCount > 0);
aTo1 = '-t tm1dude@mycompany.com';
aSubject = '-u TM1 New Client _ Password Monitor';
aBody = '-m No password change :=' | NumberToString(vCount) | ' of ' | NumberToString(recCount) | ', Expiry cleared :=' | NumberToString(xCount);
aAttach = '-a ' | FilePath | FileName | '.txt';
CmdStr = aFilePath | ' ' | aFrom | ' ' | aTo1 | ' ' | aSubject | ' ' | aBody | ' ' | aAttach | ' ' | aMailServer;
ASCIIOutput(FilePath | FileName | '_Epilog.txt', 'Cmd:= ' | CmdStr);
ASCIIOutput(FilePath | FileName | '_Epilog.txt', 'Pwd Ctl:= ' | pwdControlS, Subst(pwdControlS, 1, 8) | '_' | Subst(pwdControlS, 9, 6));
ExecuteCommand (CmdStr , 1);
EndIf;
* to enforce password changes for existing set of users, (Now - 'PasswordLastTimeUpdated') will need to change to like ~ (Now - 'WhenExpiryDaysWasSet').