+ Start a Discussion
NNRNNR 

How To send One profile users To ResetYour Password Expaire in Next 3 days..

Hi Fnds..

 In my organation i have one profile is CanadaUsers, i have send a Email to user's Reset your password with link.

Example:: Adminin can send individuals user's resetpassword link when click on Resetpassword button on profile and check the checkbox for user

like above i can send emails to all user's in particular profile


Thanks in Advance
Nnr
 
Best Answer chosen by NNR
Suneel#8Suneel#8
Below is the schedulable class. This uses default 90 days period.You need to change it according to the setting in your Org.You can schedule this class to run everyday for your requirement
 
global class PasswordExpirationReminder implements Schedulable{
    global void execute(SchedulableContext sc){
        Integer passwordExpirationDuration=90;
        Date d=Date.today()+3-passwordExpirationDuration;        
        List<User> listOfUsers=[select id,name,Email,LastPasswordChangeDate from User where LastPasswordChangeDate<:d];
        String emailMessage='Your Salesforce Password is either expired or will expire in next 3 days.Please reset your password';
        for(User u:listOfUsers){
            System.debug('Expired user:'+u.name);
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                String[] toAddresses = new String[]{String.valueOf(u.Email)};
                System.debug('Email->'+u.Email);
                mail.setToAddresses(toAddresses);
                mail.setReplyTo('noreply@salesforce.com');  
                mail.setSenderDisplayName('Salesforce Reminder');  
                mail.setSubject('Password Expiration Reminder');
                mail.setPlainTextBody(emailMessage);
                mail.setHtmlBody(emailMessage);
                Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
        }
    }
}

 

All Answers

Suneel#8Suneel#8
You can follow below path to send mail to all the users that belong to partiular profile.This way you are forcing users to reset their passwords.There is no way to send a reminder to the users asking them to reset their passwords within 3 days

Setup->Manage->Profiles->Select profile(Canada users)->View Users->Select all the users with checkbox->Reset Password(s)
NNRNNR
Hi Suneel,

  That can do in Manullay but I want to in Automatically..lik writting apex classes
Suneel#8Suneel#8
So you want to have some automated process such that it runs everyday and sends mail to users whose password gets expired in next 3 days..Is it what you want?
NNRNNR
Yes Suneel...
Suneel#8Suneel#8
Below is the schedulable class. This uses default 90 days period.You need to change it according to the setting in your Org.You can schedule this class to run everyday for your requirement
 
global class PasswordExpirationReminder implements Schedulable{
    global void execute(SchedulableContext sc){
        Integer passwordExpirationDuration=90;
        Date d=Date.today()+3-passwordExpirationDuration;        
        List<User> listOfUsers=[select id,name,Email,LastPasswordChangeDate from User where LastPasswordChangeDate<:d];
        String emailMessage='Your Salesforce Password is either expired or will expire in next 3 days.Please reset your password';
        for(User u:listOfUsers){
            System.debug('Expired user:'+u.name);
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                String[] toAddresses = new String[]{String.valueOf(u.Email)};
                System.debug('Email->'+u.Email);
                mail.setToAddresses(toAddresses);
                mail.setReplyTo('noreply@salesforce.com');  
                mail.setSenderDisplayName('Salesforce Reminder');  
                mail.setSubject('Password Expiration Reminder');
                mail.setPlainTextBody(emailMessage);
                mail.setHtmlBody(emailMessage);
                Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
        }
    }
}

 
This was selected as the best answer
NNRNNR
Hi Thanks for your Helping it will work fine and How to send Link in the code if users click on the link it open one page it ask for old password and new password and confirm new password like if click one Resetpassword button on user details it send one link to email,same like how can i implement same thing in code. thanks Thanks and Regards Ashok Gaddam cell:98 49 51 92 76
Suneel#8Suneel#8
You can add below link in the message you sent.Once user logs in,he will be getting prompt to enter the password.You need to change the below to your org server instance

https://ap1.salesforce.com/_ui/system/security/ChangePassword

Please mark this as Solved if this resolves your query