+ Start a Discussion

How to read a list of User Ids entered in an input field in visual force and reset password for them in the controller ?

I am new to Apex and I was given this requirement ,Given a list of user Ids, we would like to reset the password for those users . When there are thousands of users in an Org, it is very difficult to select the users in the UI and regenerate password for them.
User will enter a comma separated list of UserIds in a Visualforce page input field and Clicks on a button.
Apex controller is going to grab these ids and reset password for those Ids.

Need help on this.

Best Answer chosen by NIyathi
Hi Niyathi,

I have created a VF page which takes User Ids with comma sepatated as Input and on click of a button, those Users will get a Password Reset Mail.
Please find below code and Let me know if that helps you.

VF Page:
<apex:page controller="UserPwdReset" showHeader="false" sidebar="false"> 
                Enter Users(CSV):<apex:inputText value="{!UserList}" />
            <apex:commandButton value="Reset" action="{!PwdReset}" />

public class UserPwdReset{
    string[] UseIds;
    public string UserList {set;get;}
    public void PwdReset()
        UseIds = UserList.split(',');                    
        for(Id id : UseIds)
            system.resetPassword(id, true);

Best Regards,