AboutSrini Nagarajan Expertise I can answer any kind of questions in ASP.NET, C#, VB.NET, SharePoint 2007, ASP, Coldfusion, Powerbuilder 7.00 / 8.00, JAVA servlets, MS SQL 2000 / MSSQL7, Sybase
Experience Contact me if you need any custom development on ASP.NET, ASP, SharePoint 2007, Coldfusion, Powerbuilder.
Question Thanks for your reply Srini; but that is not what I'm looking for.
The 2 methods you mentioned (instr and split) will provide the login id of the user but not the full name (example from your reply: I want the asp code to return "Srini Nagarajan"-the full name registered against login id "SRINI"-when you log in as SRINI to domain/computer PSSP.
-Thanks in advance,
Parag P. Doke
-------------------------
Followup To
Question -
Hi Srini!
I a newbie at ASP and I am trying to find out the full name of the user who has logged in to my server. I'm using the IIS on Windows 2000 Prof. and my directory security has 2 options checked:
1) Basic Authentication (password is sent in clear text)
2) Integrated windows authentication
I was able to get the username in the format <DOMAIN>/<USER_NAME> using Request.ServerVariables("LOGON_USER").
What I want to know is how to get the first name and last name of the user from the network.
Please let me know if you need more info. Thanks in advance,
Parag P. Doke
Answer -
Hi
Here is the simpe code (you can do it 2 ways)
'displays: PSSP\SRINI when I login
Response.Write(Request.ServerVariables("LOGON_USER"))
Method 1
'To get only the username...
Dim strNTUser, iPos
strNTUser = RTrim(Request.ServerVariables("LOGON_USER"))
iPos = Len(strNTUser) - InStr(1, strNTUser,"\",1)
strNTUser = Right(strNTUser, iPos)
Method 2
Dim arrSomething, strNTUser
arrSomething = split(Request.ServerVariables("LOGON_USER"),"\")
strNTUser = arrSomething(1)
Happy Programming!!
Srini
Answer hi
Here is the sample code give a try
<%
'''''''''''''''''''''''''''''''''''''''''''''''''
' ADSI User Authentication Script
' Peter A. Bromberg 01/26/2001
'''''''''''''''''''''''''''''''''''''''''''''''''
' Test here for a form post ...
if request("GETUSER") = "" Then
' write out the test form
With Response
.write "<FORM ACTION=USER.ASP METHOD=POST>"
.Write "<INPUT TYPE=TEXT NAME=oDomain>ENTER DOMAIN<BR>"
.write "<INPUT TYPE=TEXT NAME=oUSer>ENTER USER NAME TO CHECK<BR>"
.write "<INPUT TYPE=PASSWORD NAME=oPassword>ENTER USER PASSWORD<BR>"
.Write "<INPUT TYPE =SUBMIT NAME=GETUSER VALUE=CHECK>"
.write "</FORM>"
end with
else
' Form was autopostback, grab the form variables ...
oDomain= Request("oDomain")
oUser = Request("oUser")
oPassword = Request("oPassword")
' begin "Kludge" VBScript error trapping (see Javascript version for
try / catch handling)
on error resume next
' Set reference to the ADSI interface to NT User Manager ...
Set objUser = GetObject("WinNT://" & oDomain & "/" & oUser )
if err.number <> 0 then
Response.write "Login Error---"
Response.end
end if
If len(objUser.FullName) < 1 then
response.write "User Not Found!"
response.end
else
on error resume next
' We verify the user password by using the ChangePassword method to change
' the password back to itself.
' Since this requires that first parameter password be correct, it's an easy' way to circumvent the fact
' that NT won't give actual access to the user's password to make a comparison. ' Be aware that on some systems,
' Admin policy settings may force the password
' to have to be changed after X number of uses
' of this method...
objUser.ChangePassword oPassword, oPassword
if err.number <> 0 then
Response.write" BAD PASSWORD!"
Response.end
else
' Now write out the ADSI User object properties that are supported by Windows 2000 ...