Automatic login for Windows users on a multi provider Claims site

By Michael Doyle posted 05-24-2011 14:47

  

If you have the option to login with multiple providers you are presented with a login page that lets you choose which option you want. The default file for this is in the hive under TEMPLATE/IDENTITYMODEL/LOGIN and is named default.aspx. If you want to automatically log on with Windows credentials (for users that are logged onto the network) you can do this with some javascript. Using this method the user will be logged on with their windows credentials if available and presented with the drop down if not (to choose FBA or their windows credentials). To do this, follow these steps.

  1. Make a copy of your default.aspx. You can work on the copy or the original. If you work on the copy you will need to change the web.config to point to the copy.
  2. Add the following javascript to default.aspx (or the copy) after the SharePointIdentity:LogonSelector control.

    <script type="text/javascript">

var wshshell=new ActiveXObject("wscript.shell");

var username=wshshell.ExpandEnvironmentStrings("%userdnsdomain%");

stsclass.innerText = username;

if(username == 'DOMAIN')

{

               var oSel = document.getElementById("ctl00$PlaceHolderMain$ClaimsLogonSelector");

               oSel.options[1].selected = true;

               oSel.onchange();

}

</script>

 

 

You will need to replace the work DOMAIN with your Windows domain. Use the total name. You can test this by using alert(‘username’) because it is the forest name. This works if the Windows option is the first one. If not then you will want to choose the index that points to Windows. You might also want to put in some error handling but this should work. You can add some additional javascript to route people to the FBA login (or whatever claims item you are using).



#claims #sharepoint #windowsid #SharePoint
0 comments
227 views