AllExperts > Experts 
Search      

Active Server Pages Programming (ASP)

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Active Server Pages Programming (ASP) Answers
Question Library

Ask a question about Active Server Pages Programming (ASP)
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Ashley Brazier
Expertise
Main focus is ASP, SQL Server 2000 & 2005

Experience
Over 6 years experience.

Education/Credentials
BCs Honours Software Design and Networks

 
   

You are here:  Experts > Computing/Technology > Business Software > Active Server Pages Programming (ASP) > errror to find username ldap adsi

Topic: Active Server Pages Programming (ASP)



Expert: Ashley Brazier
Date: 2/14/2008
Subject: errror to find username ldap adsi

Question
QUESTION: Why ????

If i use sUserName = "OI24683" the script work fine
instead if i use

sUserName = Request.ServerVariables("LOGON_USER")

to retrive the username on NT AD the scrpit go in error in:
Set oUser = GetObject("WinNT://" & sDomain & "/" & sUserName & ",user")

<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Nuova pagina 1</title>
</head>

<body>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%

Dim sUserName
Dim sDomain

sUserName = Request.ServerVariables("LOGON_USER")
sDomain = "DIP"

'sUserName = "OI24683"

Set oUser = GetObject("WinNT://" & sDomain & "/" & sUserName & ",user")

For Each oGroup In oUser.Groups
Select Case(oGroup.Name)
   Case "InpdapNAXX"
   'Response.write("InpdapNAXX")
   Response.Redirect("./default.html")
   Case "Group B"
   'response.write("Yay")
   Response.Redirect("A.asp")
   Case "Group C"
   'response.Redirect("Z.asp")
   Case "Group D"
   'Response.redirect("Y.asp")
End Select
Next
%>

</body>

</html>
</form>

ANSWER: Hi,

If you do a response.write for Request.ServerVariables("LOGON_USER") you should find the username looks something like this:-

domainname\username

You will need to remove everything before the \


Try that and let me know if you need any more help.



---------- FOLLOW-UP ----------

QUESTION: Hi friend how to "You will need to remove everything before the \"...



ANSWER: Hi,

Try this
<%
if Request.ServerVariables("LOGON_USER") = "" then
        ntusername = ""
     else
        ntusername = Request.ServerVariables("LOGON_USER")
        if instr(ntusername,"\") <> 0 then
           intLen = len(ntusername) - (instr(ntusername,"\") + 1)
           ntusername = Right(ntusername, intLen + 1)
           ntusername = lcase(ntusername)
        end if
  end if
response.write ntusername
%>

Thanks

---------- FOLLOW-UP ----------

QUESTION: get blank value in response.write

Answer
are you familar with IIS (Internet Information Services)

You will need to do the following:-

right click on the file in IIS

File Security, click on edit under Anonymous access and authentication control.
UNCHECK Anonymous Access and CHECK the integrated Windows Authentication.

This should work  

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.