RDS 2012: How to login to RDWeb page without typing Domain Name?


Logon to RDWeb site with just username and password, saves time and confusion for the users. We can make user to bypass typing Domain Name with few easy steps.

There is two steps I did. One add “DomainName\” by script and second steps to change the text from “Domain Name\User name:” to just “User name:” in logon page.

To do the first step, follow the instructions below.

For Windows 2012 R2:

1. Remote Desktop to your RD Web Access Server.

2. Open Windows Explorer and go to C:\Windows\Web\RDWeb\Pages. Backup webscripts-domain.js file.

3. Open Notepad as (run as) Administrator. Open C:\Windows\Web\RDWeb\Pages\webscripts-domain.js

4. Find strDomainName variable text. It looks like this:

var strDomainName = “”;

5. Modify the above text with your NetBIOS domain name like below: (CONTOSO is my example domain, replace it with yours).

var strDomainName = “CONTOSO”;

6. Save the file and close the Notepad.

For Windows 2012:

1. Remote Desktop to your RD Web Access Server.

2. Open Windows Explorer and go to C:\Windows\Web\RDWeb\Pages. Backup renderscripts.js file.

3. Open Notepad as (run as) Administrator. Open C:\Windows\Web\RDWeb\Pages\renderscripts.js

4. Find “strDomainUserName = objForm.elements(“DomainUserName”).value;” and add the following script blob

// add default domain…
if ( strDomainUserName.indexOf(“\\”) == -1 )
{
strDomainUserName = “INTSURG\\” + strDomainUserName;
objForm.elements(“DomainUserName”).value = strDomainUserName;
}

So it would look like this..

if ( objForm != null )
{
strDomainUserName = objForm.elements(“DomainUserName”).value;
// add default domain…
if ( strDomainUserName.indexOf(“\\”) == -1 )
{
strDomainUserName = “MYDOMAIN\\” + strDomainUserName;
objForm.elements(“DomainUserName”).value = strDomainUserName;
}
strPassword = objForm.elements(“UserPass”).value;
strWorkspaceId = objForm.elements(“WorkSpaceID”).value;

5. Save renderscripts.js file.

Now user can just provide username and password. Domain name will be added if it is not present.

Now it the RD Web access log on page will still display Domain Name\User name:. That can be changed very easily also. Follow the steps below for the second step.

For Windows Server 2012 and Windows Server 2012 R2:

1. Remote Desktop to your RD Web Access Server.

2. Open Windows Explorer and go to C:\Windows\Web\RDWeb\Pages\en-US. Backup login.aspx file.

3. Open Notepad as (run as) Administrator. Open C:\Windows\Web\RDWeb\Pages\login.aspx

4. Modify the following text as below:

Before:

const string L_DomainUserNameLabel_Text = “Domain\\user name:”;

After:

const string L_DomainUserNameLabel_Text = “User name:”;

5. Save login.aspx file.

image

That’s all. If you ever update with RDS patches, you will have to redo these steps again.

Enjoy. Smile

28 thoughts on “RDS 2012: How to login to RDWeb page without typing Domain Name?

  1. Hi, do you have found out the steps on a 2012 R2 Server. Compared to the 2012 the renderscripts.js has been redesigned.

    1. I have already changed the 2012 web.config which works for the web login. But there is a second login which I think is coming from the renderscript. Trying to find out where any help would be awesome.

  2. This works well for internal uses, however users who access from the internet can login OK but the apps fail to launch as it prompts unable to connect. When the internet user enters Domain\Username they can launch the remote apps fine?? Any ideas what else needs to be changed to make this work for RDS users?

    1. Hello Joe,
      Single sign-on (windows authentication) will not work from Internet and it can’t possible. My solution is to keep two RDS Web Access servers. One web access server for Internal users with Windows Authentication and Other one for Internet users with Form-based authentication.

      Anand

  3. I tried the 2012 R2 steps and cannot get this to work, i editied the line var strDomainName = “mydomainname”; and followed the steps to delete the Domain\ from the logon page. When i try to login i get the error You must enter a valid domain name. I tried restarting IIS still not working. Please can you help

    1. mmm..I am not sure what’s happening on your RDS Web access server. I want to ask you some obvious question.

      Can you double check the strDomainName variable in C:\Windows\Web\RDWeb\Pages\webscripts-domain.js

      Anand

  4. Thank you for your fantastic blog. I appreciate the detail yet simplicity that you incorporate into each post. This particular post worked perfectly for me. I have also applied the steps from your post about adding the ability for users to change their password. Do you know of a way to change the password.aspx to not require a domain as well? It does not appear to pull the domain from the webscripts-domain.js file.

  5. Anand, for whatever reason, the sign out is no longer working after modifying the files as you described. Anything I hacked wrongly????

      1. It’s weird. I can click on sign out and just nothing happens.Should I reboot the Web Access server?

  6. Thanks Anand, it’s still not letting me sign out but it’s no biggie.
    Thanks for the great write-up.
    Dennis

  7. I too have the same problem. Windows 2012 and I cant sign out or use the Help button once I made this change…..?

      1. That makes sense. Strangely, the help button right beside it doesn’t work either. I can click it but it does nothing. If I take that change to renderscripts back out then it works like normal

      2. Anand, I am having the same issue as Dennis and Steven on Windows 2012, After making the changes I can sign in without domain name, but it removes the options under Security – the public or private computer radio buttons, the ability to sign out and click help.
        Any ideas?

  8. Works like a charm. But I also wonder if you can get this to work in password.aspx as well? Doesn’t seem to work on either 2012 or 2012R2.

  9. At least for 2012 R2, the given solution wasn’t working for me. After the change made, yes, I was able to login to Web Access interface without specifying domain name, but then no published application could be launched, I was getting error message from RDP client.

    The problem is, strDomainName variable in webscripts-domain.js isn’t passed to RDP client, it is used just to check if user has entered domain name. Only strDomainUserName is really passed to the client engine, so we need to modify it and inject default domain name if it wasn’t set. So I made the following change to function strDomainUserName in webscripts-domain.js:

    if ( -1 != strDomainUserName.indexOf(“\\”) )
    {
    strDomainName = strDomainUserName.substring( 0, strDomainUserName.indexOf(“\\”) );
    }
    else if ( -1 != strDomainUserName.indexOf(“@”) )
    {
    strDomainName = strDomainUserName.substring( strDomainUserName.indexOf(“@”) + 1, strDomainUserName.length );
    }
    else
    {
    strDomainUserName = strDomainName + “\\” + strDomainUserName;
    }

    (The last “else” block is added.)

    This change caused new problem: after logon to Web Access I was receiving a message that connection is used by another user, and then logoff was forced. After a brief search, I’ve found a check in renderscripts.js which compares user name from cookie with the one passed in the form:

    if ( strDomainUserName.toLowerCase() == strLoggedOnDomainUserName.toLowerCase()) {
    ….
    }
    else
    {
    //
    // Ideally check workspace state before redirecting; if it has been authenticatd as well.
    //
    window.location = strBaseUrl + “LogOff.aspx” + strQueryStringPreamble + “Error=WkSInUse”;
    }

    So another change was needed, now to renderscripts.js. First, I’ve added new function, which attaches default domain name to user name if there is none:

    function getUserNameWithDomain(strUserName)
    {
    if ((strUserName != null) && (strUserName != “”) && (strUserName.indexOf(“\\”) == -1) && (strUserName.indexOf(“@”) == -1))
    {
    strUserName = “MYDOMAINNAME\\” + strUserName;
    }
    return strUserName;
    }

    And then used this function on user name extractions.
    In onAuthenticated function:

    var strLoggedOnDomainUserName = getUserNameWithDomain(objForm.elements[“DomainUserName”].value);

    var strLoggedOnDomainUserName = getUserNameWithDomain(objForm.elements[“DomainUserName”].value);

    And in getUserNameRdpProperty function:

    var strDomainUserName = getUserNameWithDomain(decodeURIComponent( getCookieCrumbValue(strCookieContents, “Name”) ));

    Then it really works for me.

  10. If you have those awesome users that get confused with appending text, drop this in renderscripts.js at the end of onPageload(e):

    var dun = document.getElementById(“DomainUserName”);
    var myDomain = “MYDOUGHMEIN”;
    dun.onblur = function() {
    var txt = dun.value.replace(/^\s\s*/, ”).replace(/\s\s*$/, ”);
    if(txt.length==0) return;
    var iAt = txt.indexOf(‘@’);
    while (iAt>-1) {
    txt = txt.substring(0,iAt);
    iAt = txt.indexOf(‘@’);
    }
    var iSlash = txt.lastIndexOf(“\\”);
    while(iSlash>-1) {
    txt = txt.substring(iSlash+1);
    iSlash = txt.lastIndexOf(“\\”);
    }
    if(txt.substring(0,myDomain.length+1).toLowerCase()!=myDomain + “\\”&&txt.length>0) txt = myDomain + “\\” + txt;
    this.value = txt;
    };

Leave a comment