With winter 16 we have issue with password lockout when we have two factor enabled
Click here to see the issue
We are experiencing so many lockouts so I came up with this
global class scheduledPasswordReset implements Schedulable {
global void execute(SchedulableContext SC) {
Set<String> Ids = new Set<String>();
Set<String> LockIds = new Set<String>();
for (LoginHistory l : [SELECT UserId,LoginTime, status FROM LoginHistory WHERE LoginTime = TODAY ORDER BY LoginTime DESC ]){
if(!Ids.contains(l.userId)){
Ids.add(l.userId);
if(l.status == 'Password Lockout'){
LockIds.add(l.userId);
}
}
}
system.debug('### '+LockIds);
for(String uId : LockIds){
System.resetPassword(uId, true);
}
}
}
Click here to see the issue
We are experiencing so many lockouts so I came up with this
global class scheduledPasswordReset implements Schedulable {
global void execute(SchedulableContext SC) {
Set<String> Ids = new Set<String>();
Set<String> LockIds = new Set<String>();
for (LoginHistory l : [SELECT UserId,LoginTime, status FROM LoginHistory WHERE LoginTime = TODAY ORDER BY LoginTime DESC ]){
if(!Ids.contains(l.userId)){
Ids.add(l.userId);
if(l.status == 'Password Lockout'){
LockIds.add(l.userId);
}
}
}
system.debug('### '+LockIds);
for(String uId : LockIds){
System.resetPassword(uId, true);
}
}
}
No comments:
Post a Comment