Transaction security policy for multiple logins
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
2
down vote
favorite
I need to modify the existing transaction security policy to trigger if user logs in from multiple IP addresses in past 8 hours. I'm using the below SFDC example policy. Can someone give a hand on how to tweak the below code to trigger for 8 hours. Currently the policy is configured to trigger for past 24 hours.
global class LoginPolicyCondition implements TxnSecurity.PolicyCondition
public boolean evaluate(TxnSecurity.Event e)
AggregateResult results = [SELECT SourceIp
FROM LoginHistory
WHERE UserId = :e.userId
AND LoginTime = LAST_N_DAYS:1
GROUP BY SourceIp];
if(!results.isEmpty() && results.size() > 1)
return true;
return false;
transaction shield
add a comment |Â
up vote
2
down vote
favorite
I need to modify the existing transaction security policy to trigger if user logs in from multiple IP addresses in past 8 hours. I'm using the below SFDC example policy. Can someone give a hand on how to tweak the below code to trigger for 8 hours. Currently the policy is configured to trigger for past 24 hours.
global class LoginPolicyCondition implements TxnSecurity.PolicyCondition
public boolean evaluate(TxnSecurity.Event e)
AggregateResult results = [SELECT SourceIp
FROM LoginHistory
WHERE UserId = :e.userId
AND LoginTime = LAST_N_DAYS:1
GROUP BY SourceIp];
if(!results.isEmpty() && results.size() > 1)
return true;
return false;
transaction shield
This is mostly identical to this question but with more context. Please edit your questions to expand on them rather than creating duplication.
– David Reed
4 hours ago
David - I deleted the identical question since it was duplicate as you pointed. Thanks
– VBALearner
4 hours ago
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I need to modify the existing transaction security policy to trigger if user logs in from multiple IP addresses in past 8 hours. I'm using the below SFDC example policy. Can someone give a hand on how to tweak the below code to trigger for 8 hours. Currently the policy is configured to trigger for past 24 hours.
global class LoginPolicyCondition implements TxnSecurity.PolicyCondition
public boolean evaluate(TxnSecurity.Event e)
AggregateResult results = [SELECT SourceIp
FROM LoginHistory
WHERE UserId = :e.userId
AND LoginTime = LAST_N_DAYS:1
GROUP BY SourceIp];
if(!results.isEmpty() && results.size() > 1)
return true;
return false;
transaction shield
I need to modify the existing transaction security policy to trigger if user logs in from multiple IP addresses in past 8 hours. I'm using the below SFDC example policy. Can someone give a hand on how to tweak the below code to trigger for 8 hours. Currently the policy is configured to trigger for past 24 hours.
global class LoginPolicyCondition implements TxnSecurity.PolicyCondition
public boolean evaluate(TxnSecurity.Event e)
AggregateResult results = [SELECT SourceIp
FROM LoginHistory
WHERE UserId = :e.userId
AND LoginTime = LAST_N_DAYS:1
GROUP BY SourceIp];
if(!results.isEmpty() && results.size() > 1)
return true;
return false;
transaction shield
transaction shield
asked 5 hours ago
VBALearner
112
112
This is mostly identical to this question but with more context. Please edit your questions to expand on them rather than creating duplication.
– David Reed
4 hours ago
David - I deleted the identical question since it was duplicate as you pointed. Thanks
– VBALearner
4 hours ago
add a comment |Â
This is mostly identical to this question but with more context. Please edit your questions to expand on them rather than creating duplication.
– David Reed
4 hours ago
David - I deleted the identical question since it was duplicate as you pointed. Thanks
– VBALearner
4 hours ago
This is mostly identical to this question but with more context. Please edit your questions to expand on them rather than creating duplication.
– David Reed
4 hours ago
This is mostly identical to this question but with more context. Please edit your questions to expand on them rather than creating duplication.
– David Reed
4 hours ago
David - I deleted the identical question since it was duplicate as you pointed. Thanks
– VBALearner
4 hours ago
David - I deleted the identical question since it was duplicate as you pointed. Thanks
– VBALearner
4 hours ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
There is no SOQL Date Literal equivalent to to LAST_N_DAYS:1
that will give you a period of 8 hours.
Instead, you can just calculate the date range and use that in the SOQL query instead.
DateTime eightHoursAgo = DateTime.now().addHours(-8);
AggregateResult results = [SELECT SourceIp
FROM LoginHistory
WHERE UserId = :e.userId
AND LoginTime >= :eightHoursAgo
GROUP BY SourceIp];
return (!results.isEmpty() && results.size() > 1);
That makes perfect sense. Appreciate your help on this.
– VBALearner
4 hours ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
There is no SOQL Date Literal equivalent to to LAST_N_DAYS:1
that will give you a period of 8 hours.
Instead, you can just calculate the date range and use that in the SOQL query instead.
DateTime eightHoursAgo = DateTime.now().addHours(-8);
AggregateResult results = [SELECT SourceIp
FROM LoginHistory
WHERE UserId = :e.userId
AND LoginTime >= :eightHoursAgo
GROUP BY SourceIp];
return (!results.isEmpty() && results.size() > 1);
That makes perfect sense. Appreciate your help on this.
– VBALearner
4 hours ago
add a comment |Â
up vote
2
down vote
There is no SOQL Date Literal equivalent to to LAST_N_DAYS:1
that will give you a period of 8 hours.
Instead, you can just calculate the date range and use that in the SOQL query instead.
DateTime eightHoursAgo = DateTime.now().addHours(-8);
AggregateResult results = [SELECT SourceIp
FROM LoginHistory
WHERE UserId = :e.userId
AND LoginTime >= :eightHoursAgo
GROUP BY SourceIp];
return (!results.isEmpty() && results.size() > 1);
That makes perfect sense. Appreciate your help on this.
– VBALearner
4 hours ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
There is no SOQL Date Literal equivalent to to LAST_N_DAYS:1
that will give you a period of 8 hours.
Instead, you can just calculate the date range and use that in the SOQL query instead.
DateTime eightHoursAgo = DateTime.now().addHours(-8);
AggregateResult results = [SELECT SourceIp
FROM LoginHistory
WHERE UserId = :e.userId
AND LoginTime >= :eightHoursAgo
GROUP BY SourceIp];
return (!results.isEmpty() && results.size() > 1);
There is no SOQL Date Literal equivalent to to LAST_N_DAYS:1
that will give you a period of 8 hours.
Instead, you can just calculate the date range and use that in the SOQL query instead.
DateTime eightHoursAgo = DateTime.now().addHours(-8);
AggregateResult results = [SELECT SourceIp
FROM LoginHistory
WHERE UserId = :e.userId
AND LoginTime >= :eightHoursAgo
GROUP BY SourceIp];
return (!results.isEmpty() && results.size() > 1);
answered 5 hours ago
Daniel Ballinger
70.8k15145377
70.8k15145377
That makes perfect sense. Appreciate your help on this.
– VBALearner
4 hours ago
add a comment |Â
That makes perfect sense. Appreciate your help on this.
– VBALearner
4 hours ago
That makes perfect sense. Appreciate your help on this.
– VBALearner
4 hours ago
That makes perfect sense. Appreciate your help on this.
– VBALearner
4 hours ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f238557%2ftransaction-security-policy-for-multiple-logins%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
This is mostly identical to this question but with more context. Please edit your questions to expand on them rather than creating duplication.
– David Reed
4 hours ago
David - I deleted the identical question since it was duplicate as you pointed. Thanks
– VBALearner
4 hours ago