I'm no expert with all this but the following method will force a user to
change their password on next log in.
This does one user at a time. I don't know of a way to do this in bulk.
Since this would be done infrequently that might be OK.
The method below that gets all the users, 100 at a time and checks if is a
staff account. If so, it does forceUserToChangePassword
The second method was altered from its original purpose so may need some
work. I have been toying with the idea of making a series of single purpose
java programs that do tasks like this one. If your interested maybe we could
come up with a basic framework that we could use as a starting point for
modules like this one and make them available as open source on Google Code.
/**
* Require a user to change password at next login. Note that
executing this
* method for a user who is already required to change password at
next login
* as no effect.
*
* @param username The user who must change his or her password.
* @throws AppsForYourDomainException If a Provisioning API specific
occurs.
* @throws ServiceException If a generic GData framework error occurs.
* @throws IOException If an error occurs communicating with the GData
* service.
*/
public UserEntry forceUserToChangePassword(String username)
throws AppsForYourDomainException, ServiceException, IOException {
if(gmailAllowCreation){
Notify.info( "Requiring " + username + " to change password at " +
"next login.");
URL retrieveUrl = new URL(domainUrlBase + "user/"
+ SERVICE_VERSION + "/" + username);
UserEntry userEntry = userService.getEntry(retrieveUrl,
UserEntry.class);
userEntry.getLogin().setChangePasswordAtNextLogin(true);
URL updateUrl = new URL(domainUrlBase + "user/"
+ SERVICE_VERSION + "/" + username);
return userService.update(updateUrl, userEntry);
}else{
return null;
}
}
public int setForcePasswordChangeOnStaffAccounts() {
int userCount = 0;
int staffUserCount = 0;
FileHandler fh;
try {
fh = new FileHandler(System.getProperty("user.dir") +
"/test.log");
fh.setFormatter(new SimpleFormatter());
LOGGER.addHandler(fh);
} catch (SecurityException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
try{
PrintWriter out = new PrintWriter(new BufferedWriter(new
FileWriter("staffUsers.txt", true)));
String filename = "test.log";//"staffUsers.txt";
TailerFrame tf = new TailerFrame(System.getProperty("user.dir") +
System.getProperty("file.separator") + filename, 1000,
true);//System.getProperty("user.dir") +
System.getProperty("file.separator") +
this.desktop.add( tf );
tf.setTitle( filename);
this.getContentPane().add( desktop, BorderLayout.CENTER );
this.setSize( 1000, 700 );
this.setVisible( true );
this.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
URL retrieveUrl = new URL(domainUrlBase + "user/" + SERVICE_VERSION
+ "/");
UserFeed currentPage;
Link nextLink;
int currentPageCount = 0;
do {
currentPage = userService.getFeed(retrieveUrl,
UserFeed.class);
List<UserEntry> uel = currentPage.getEntries();
ListIterator<UserEntry> li = uel.listIterator();
while (li.hasNext()){
UserEntry ue = (UserEntry) li.next();
String username = ue.getLogin().getUserName();
if(username.contains(".")){//staff have a dot in
username, students don't
staffUserCount ++;
try {
forceUserToChangePassword(username);
LOGGER.log(Level.INFO, userCount + " " +
username + " force password has been set ");
out.println(username);
out.flush();
} catch (InvalidUserException e) {
e.printStackTrace();
} catch (ServiceException e){
e.printStackTrace();
} catch (MalformedURLException e){
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
}
userCount++;
}
nextLink = currentPage.getLink(Link.Rel.NEXT, Link.Type.ATOM);
if (nextLink != null) {
retrieveUrl = new URL(nextLink.getHref());
currentPageCount ++;
LOGGER.log(Level.INFO, "Current Page Count is " +
currentPageCount);
}
} while (nextLink != null );// add this to the while for testing
so all pages are not returned && currentPageCount < 6 );
out.close();
} catch (AppsForYourDomainException e) {
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JOptionPane.showMessageDialog(null,
staffUserCount + " staff users have had their force password
set .\n\n"
+ "Total users count is " + userCount);
return staffUserCount;
}
On Mon, Nov 24, 2008 at 4:39 PM, nToronto <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> Currently, an admin user can manually go into each user account and
> click a checkbox which requires that specific user to change his
> password when he next logs into Google Apps. However, there is no way
> to require ALL users to change their passwords during the next login.
>
> Is there any way to use the Email Settings API, force *ALL* users to
> change their passwords during their next login?
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Apps APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-apps-apis?hl=en
-~----------~----~----~----~------~----~------~--~---