Set up is fairly simple, you can just copy and paste the code from below into a Google Apps Script File, or click here to create your own copy by selecting File -> Make a Copy.

Then just click save new version. (You don't have to type anything in the box.) Now click Publish -> Deploy as web app.

Choose the settings as shown below. (Of course the last one will show your domain, not lths.org)

Now the web app is deployed. Use the link that pops up to share it. The final step is to control which users have access to this script. You do this by granting access to the provisioning API in the Google Apps Control Panel. To do this you will need super admin rights to the control panel.
Start by going to the Domain Settings tab, then the Admin roles tab. Then click create new role. Give the new role a name. (If you prefer, you can use an existing user created role)

Within this role, scroll down to the bottom and look for the Provisioning API's section. Click users. (This should automatically check the 4 columns to the right.) Click save changes.

Finally, assign admins to this role. They will have to authorize the scrip the first time they use it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This the initial app screen | |
function doGet() { | |
//create the application | |
var app = UiApp.createApplication(); | |
//create the vertical panel to hold widgets | |
var vp = app.createVerticalPanel().setId('vp'); | |
//style the vertial panel | |
vp.setBorderWidth(5).setStyleAttribute("border-color", "maroon").setStyleAttribute("font-weight", "bold"); | |
//Create the label, text input box and button widgets | |
var label = app.createLabel('Enter the username that you would like to reset.'); | |
var input = app.createTextBox().setName('input').setId('input'); | |
var button = app.createButton('Submit'); | |
//add the widgets to the vertical panel | |
vp.add(label); | |
vp.add(input); | |
vp.add(button); | |
//add the vertical panel to the app | |
app.add(vp); | |
//create a server handler for the next function | |
var handler = app.createServerHandler('confirm'); | |
//add the text input box as a callback element to the server handler | |
handler.addCallbackElement(input); | |
//assign the server handler to the button | |
button.addClickHandler(handler); | |
return app; | |
} | |
//this function will confirm that we have the right user | |
function confirm(e) { | |
//get the app instance | |
var app = UiApp.getActiveApplication(); | |
//get the existing vertical panel and make it invisible, I probably could just clear widgets instead | |
vp = app.getElementById('vp'); | |
vp.setVisible(false); | |
//create and style a new panel | |
vp2 = app.createVerticalPanel().setId('id2'); | |
vp2.setBorderWidth(5).setStyleAttribute("border-color", "maroon").setStyleAttribute("font-weight", "bold"); | |
//get the value from the text input box | |
username = e.parameter.input; | |
//create a hidden widget that will pass the value of the username to the next function | |
hidden = app.createHidden('username',username).setId('hidden'); | |
app.add(hidden); | |
//get the instance of the user | |
user = UserManager.getUser(username); | |
//get the first and last name of the user | |
givenName = user.getGivenName(); | |
familyName = user.getFamilyName(); | |
//create a label and button widgets | |
label = app.createLabel('Clicking the Reset button below will reset the password for '+givenName+" "+familyName); | |
button = app.createButton('Reset'); | |
//add the widgets to the vertical panel | |
vp2.add(label); | |
vp2.add(button) | |
//add the vertical panel to the app | |
app.add(vp2); | |
//create a server handler for the next function | |
var handler = app.createServerHandler('reset'); | |
//add the hidden widget as a callback element to the server handler | |
handler.addCallbackElement(hidden); | |
//assign the server handler to the button | |
button.addClickHandler(handler); | |
return app; | |
} | |
//this function will actually reset the password | |
function reset(e) { | |
//get the app instance | |
var app = UiApp.getActiveApplication(); | |
//get the existing vertical panel and make it invisible, I probably could just clear widgets instead | |
vp2 = app.getElementById('id2'); | |
vp2.setVisible(false); | |
//get the value from the hidden widget | |
username = e.parameter.username | |
//get the instance of the user | |
user = UserManager.getUser(username); | |
//SET YOUR DEFAULT PASSWORD HERE | |
var password = 'your_custom_default_password' | |
//reset the password to porters12 and force a password change | |
user.setChangePasswordAtNextLogin(true).setPassword(password); | |
//create and style a new panel | |
vp3 = app.createVerticalPanel(); | |
vp3.setBorderWidth(5).setStyleAttribute("border-color", "maroon").setStyleAttribute("font-weight", "bold"); | |
//create a label that logs what happened | |
label = app.createLabel('The password for '+username+' has been reset to the default.'); | |
//add the label to the panel and panel to the app | |
vp3.add(label); | |
app.add(vp3); | |
return app; | |
} |
Good blog. Also visit http://www.cloudcodes.com/
ReplyDeleteThanks brainmine, i like the website you have suggested. Infact the password policy tool is very useful . Folks try it out password reset tool for google apps Visit for more information at http://www.cloudcodes.com/password-policy.html
ReplyDeleteExcellent article.I am very happy to see this type article .I am also trying to write this type article with the help of custom essay writing services guidelines.I am eagerly waiting for your new stuff.
ReplyDeleteWe have some good suggestions to reset password by using Google App. The author explained it in a good manner and the screenshots pass the idea quickly. It helps the users to catch the procedures.
ReplyDeletehttp://essaywriting-servicereviews.com/Forum-Health-and-Food
http://essaywriting-servicereviews.com/Forum-Cinema-TV-Shows-Music
http://essaywriting-servicereviews.com/Forum-Religion-Spirituality