|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Retrieving network authentication information - ASP/jscript
I am tryign to pull a user's network UserID to use to authenticate against an MS SQL server. I can hardcode the information in so I know that I can actually accomplish the task. My problem is stripping away the domain information. Here is what I have.
jscript function (my problem) <script language="JavaScript"> function fnGetUserID(sUserID) { sUserID = Trim(sUserID); var iPos = IndexOf(sUserID,"/"); sUserID = sUserID.SubStr(iPos+1); return sUserID; } I beleive the reason this fails is because SubStr expects a string object and I am passing a string data type. Or so goes teh theory. I'm sure this is something really easy and will make many of you just laugh at my inferior knowledge ... your assistance is appreciated. |
|
#2
|
||||
|
||||
|
well for one, substr() takes two parameters 1) where to start and 2) how many characters the string will be. I think the logic between
var iPos = IndexOf(sUserID,"/"); sUserID = sUserID.SubStr(iPos+1); ...is incorrect. How many characters is the sUserID supposed to be and do you expect the "/" to be in front of behind the target id? Can you give an example of a value you think could be passed into this function? I can help if I see what you start with and have an idea of what you want at the end. |
|
#3
|
|||
|
|||
|
domain/userID where userID is an individuals network login - first initial+up to first 6 of lastname. Unfortunately some folks have small last names so there is not strict 7 character rule.
|
|
#4
|
||||
|
||||
|
this should work for you
Code:
<script language="JavaScript">
function fnGetUserID(sUserID)
{
sUserID = sUserID.toString();
var iPos = sUserID.indexOf("/");
sUserID = sUserID.substring(iPos+1,sUserID.length);
return sUserID;
//document.write(sUserID);
}
</script>
|
|
#5
|
||||
|
||||
|
i commented out the document.write() on purpose. If you uncomment it then you can see the product of the code displayed on the screen
|
|
#6
|
|||
|
|||
|
Use SPLIT to separate domain\username
ArUserInfo=sUserID.split(/\\/);
alert("Domain: "+ArUserInfo[1]+" User: "+ArUserInfo[0]); |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Retrieving network authentication information - ASP/jscript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|