Pages

Monday, May 30, 2011

Clear Authentication Cache - Javascript

If we use http authentication, at the moment we want to logout a user for good, there's some issues we have to be aware of. So, we want to logout a user at client side and make sure that no one else has access to his/her account when using the same browser to access the same portal for instance. For IE, early versions, is pretty easy, we just do the code below:

// Clear current credentials
// Requires IE6 SP1 or later
document.execCommand(ClearAuthenticationCache)


Unfortunately, the ClearAuthenticationCache command is not available to others browsers in this case, so in order to do this really need to close the browser or, if it works for you, make an ajax call with wrong credentials to make your latest credentials saved to browser authentication cache be a 401 for that site. Mixing this all together we can have a javascript code like this one:




























References:
http://www.adopenstatic.com/cs/blogs/ken/archive/2005/04/12/14.aspx
http://stackoverflow.com/questions/31326/is-there-a-browser-equivalent-to-ies-clearauthenticationcache
http://stackoverflow.com/questions/1205045/how-to-clear-authentication-cache-on-ie7-with-javascript
http://www.nanodocumet.com/?p=6
http://msdn.microsoft.com/en-us/library/ms536979(v=vs.85).aspx
http://code.google.com/p/chromium/issues/detail?id=5497
http://trac-hacks.org/wiki/TrueHttpLogoutPatch

Saturday, May 28, 2011

Alter Sharepoint Timer Job Schedule - Object Model

If you want to alter a Sharepoint Timer Job Schedule without uninstall it, you can do it by an STSADM command like this one:
stsadm -o setcontentdeploymentjobschedule  -jobname "YourJobName"  -schedule "Weekly between Fri 22:00:00 and Sun 06:00:00"

But, this is only available if you are using MOSS. This stsadm command isn't available in WSS's, so in order to alter an timer job's schedule without going through all uninstall and install feature process, you can go by object model.

To simplify, we do a Console Application to comply our purpose. At main method...














And to finish we just do like this:































Done! ;)

References:
http://blogs.technet.com/b/josebda/archive/2008/03/15/complete-reference-of-all-stsadm-operations-with-parameters-in-moss-2007-sp1.aspx
http://social.technet.microsoft.com/Forums/en-US/sharepointadmin/thread/b29627df-ac9f-4eff-9d83-bf57a03848a8
http://www.codeguru.com/cpp/misc/misc/microsoftofficeoutlook/print.php/c14133