I'm working on a project here where I have an ASP FBA login page that has three fields:
USERNAME:
PASSWORD:
RSA PASSCODE:
And with this users must prepend their domain to the username for authentication to succeed as the system is required to auth them against several different domains > "domain\username"
Problem is that a lot of users dont remember the domain part so what I've done is add a little logic to the page that provides users with a drop down selection box that contains the domains which I've placed in an array. This would make the whole user experience
that much more friendly.
USERNAME:
SELECT DOMAIN
PASSWORD:
RSA PASSCODE:
The code I've added is as follows.....
<HEAD>
<%
Dim strDomains(1)
strDomains(0)="Lionrock" 'Domain1
strDomains(1)="RedRock" 'Domain2
%>
</HEAD>
<BODY>
<TR>
<TD class="paramText"><%=GetString(1112, "Select Domain:")%></TD>
<TD>
<select class="paramTextbox" ID="DomList" NAME="DomList" onkeypress="keyDetect(event)">
<%For Each item In strDomains
value = item
if Session("Dom") = value then
Response.write("<option value=""" & value & """ selected>" & value & "</option>")
else
Response.write("<option value=""" & value & """>" & value & "</option>")
end if Next%>
</select>
</TD>
</TR>
</BODY>
Challenge I have is that I'm really not sure about how to have the code take the domain that the user has selected from the list and automatically prepend that to the username when the form is being submited.
I'm hoping someone might be able to point me in the right direction?
Hey! I'm just back from a long and well deserved break so hope my replys' still useful
What I did was use one of the methods in the overflow links and came up with this..
<%
' Cookie check
Dim DiscCookie
DiscCookie = Request.Cookies("NLSession.dom")
If DiscCookie <> "nota" Then
Discstate = 0
Else
Discstate = 1
End if
%>
<HTML>
<HEAD>
<!-- Inject domain -->
<SCRIPT>
function wrapSearch() {
var text = document.getElementById('user_name');
var doms = document.getElementById('language');
text.value = doms.value + "\\" +text.value ;
}
<!-- Set cookie -->
function AuthDom()
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + 365);
var c_value="agreed; expires="+exdate.toUTCString()+";path=/";
document.cookie="NLSession.dom" + "=" + c_value;
}
</SCRIPT>
<%
' Domains list array
Dim strDomains(1)
strDomains(0)="EXTDOMAIN"
strDomains(1)="INTDOMAIN"
%>
</HEAD>
<BODY>
<FORM id=form1 name=form1 autocomplete="off" method=post action="/InternalSite/Validate.asp" onsubmit="wrapSearch()";>
<TD><INPUT class="paramTextbox" TYPE="text" ID="user_name" NAME="user_name" maxLength="18" size="11"></TD>
<TR>
<TD class="paramText"><%=GetString(1112, "Select Domain:")%></TD>
<TD>
<select class="paramTextbox" ID="language" NAME="language" onchange="AuthDom()";>
<%
For Each item In strDomains
value = item
if Discstate = 1 then
Response.write("<option value=""" & value & """ selected>" & value & "</option>")
else
Response.write("<option value=""" & value & """>" & value & "</option>")
end if
Next
%>
</select>
</TD>
</TR>
<input border="0" class="button" type="submit" id="submit_button" value="Log On">
</BODY>
</HTML>
The final page itself contains a lot more code but the above is basically what achieves this functionaility, and the result is that you see the wrapsearch function inject a "domain\" before the username and users can authenticate without having to enter
this themselves.
Works perfectly! Next step is I'd like to try and make this "domain\" invisible so we don't see it flash up in the username input box. Instead it would just silently do this in the background. Maybe using display="hidden" or something like that, I'm not
sure yet but I'm going to try. Thanks and any suggestions welcome!
ramara
Member
16 Points
13 Posts
Progamatically adding "domain\" to username when submiting form
Apr 29, 2012 06:52 PM|LINK
Hi folks,
I'm working on a project here where I have an ASP FBA login page that has three fields:
USERNAME:
PASSWORD:
RSA PASSCODE:
And with this users must prepend their domain to the username for authentication to succeed as the system is required to auth them against several different domains > "domain\username"
Problem is that a lot of users dont remember the domain part so what I've done is add a little logic to the page that provides users with a drop down selection box that contains the domains which I've placed in an array. This would make the whole user experience that much more friendly.
USERNAME:
SELECT DOMAIN
PASSWORD:
RSA PASSCODE:
The code I've added is as follows.....
<HEAD> <% Dim strDomains(1) strDomains(0)="Lionrock" 'Domain1 strDomains(1)="RedRock" 'Domain2 %> </HEAD> <BODY> <TR> <TD class="paramText"><%=GetString(1112, "Select Domain:")%></TD> <TD> <select class="paramTextbox" ID="DomList" NAME="DomList" onkeypress="keyDetect(event)"> <%For Each item In strDomains value = item if Session("Dom") = value then Response.write("<option value=""" & value & """ selected>" & value & "</option>") else Response.write("<option value=""" & value & """>" & value & "</option>") end if Next%> </select> </TD> </TR> </BODY>Challenge I have is that I'm really not sure about how to have the code take the domain that the user has selected from the list and automatically prepend that to the username when the form is being submited.
I'm hoping someone might be able to point me in the right direction?
Help!
ramara
Member
16 Points
13 Posts
Re: Progamatically adding "domain\" to username when submiting form
May 01, 2012 07:47 AM|LINK
Anyone have any ideas?
kranthireddy...
Participant
790 Points
167 Posts
Re: Progamatically adding "domain\" to username when submiting form
May 01, 2012 11:57 AM|LINK
var e = document.getElementById("DomList");
var strUser = e.options[e.selectedIndex].text;
sometextbox.value=strUser+"/"+sometextbox.value -- this is updating you text box value once the domain is selected.
Get the value of the dropdown list and then add it to the text box using javascript.
http://stackoverflow.com/questions/1085801/how-to-get-selected-value-of-dropdownlist-using-javascript
http://stackoverflow.com/questions/1106199/getting-the-value-of-a-dropdownlist-after-client-side-javascript-modification
ramara
Member
16 Points
13 Posts
Re: Progamatically adding "domain\" to username when submiting form
May 13, 2012 09:34 AM|LINK
Thanks so much Kranthi, with a litle tweaking that did the job perfectly!!
kranthireddy...
Participant
790 Points
167 Posts
Re: Progamatically adding "domain\" to username when submiting form
May 14, 2012 12:56 PM|LINK
You are welcome buddy, can you post the tweak you have done in your code for my understanding ?
ramara
Member
16 Points
13 Posts
Re: Progamatically adding "domain\" to username when submiting form
May 21, 2012 09:11 PM|LINK
Hey! I'm just back from a long and well deserved break so hope my replys' still useful
What I did was use one of the methods in the overflow links and came up with this..
<% ' Cookie check Dim DiscCookie DiscCookie = Request.Cookies("NLSession.dom") If DiscCookie <> "nota" Then Discstate = 0 Else Discstate = 1 End if %> <HTML> <HEAD> <!-- Inject domain --> <SCRIPT> function wrapSearch() { var text = document.getElementById('user_name'); var doms = document.getElementById('language'); text.value = doms.value + "\\" +text.value ; } <!-- Set cookie --> function AuthDom() { var exdate=new Date(); exdate.setDate(exdate.getDate() + 365); var c_value="agreed; expires="+exdate.toUTCString()+";path=/"; document.cookie="NLSession.dom" + "=" + c_value; } </SCRIPT> <% ' Domains list array Dim strDomains(1) strDomains(0)="EXTDOMAIN" strDomains(1)="INTDOMAIN" %> </HEAD> <BODY> <FORM id=form1 name=form1 autocomplete="off" method=post action="/InternalSite/Validate.asp" onsubmit="wrapSearch()";> <TD><INPUT class="paramTextbox" TYPE="text" ID="user_name" NAME="user_name" maxLength="18" size="11"></TD> <TR> <TD class="paramText"><%=GetString(1112, "Select Domain:")%></TD> <TD> <select class="paramTextbox" ID="language" NAME="language" onchange="AuthDom()";> <% For Each item In strDomains value = item if Discstate = 1 then Response.write("<option value=""" & value & """ selected>" & value & "</option>") else Response.write("<option value=""" & value & """>" & value & "</option>") end if Next %> </select> </TD> </TR> <input border="0" class="button" type="submit" id="submit_button" value="Log On"> </BODY> </HTML>The final page itself contains a lot more code but the above is basically what achieves this functionaility, and the result is that you see the wrapsearch function inject a "domain\" before the username and users can authenticate without having to enter this themselves.
Works perfectly! Next step is I'd like to try and make this "domain\" invisible so we don't see it flash up in the username input box. Instead it would just silently do this in the background. Maybe using display="hidden" or something like that, I'm not sure yet but I'm going to try. Thanks and any suggestions welcome!