Hello All,
This is my first post here at the JR. Been reading the posts on the sidelines for a while. I have an Active Server Page question. Dont worry peeps, I have my SCJP2, but stuck in a Microsoft shop. Benn trying for a while to get some
Java projects in here but upper manamgement is lame. What can you do.
Anyway my question is about retrieving the logon user's full name from an ASP page. We have a time sheet application that needs the full name to reference our employee data table for our timsheets application to work(I know what if there are 2 guys with same first and lastname, I hear ya, but its a small company, and i didn't set up the database). Our code was working fine when we were using WindowsNT but the geniuses in the IT department decided to upgrade to Windows2000 Active Directory without thinking of any of the implications. Below is the code we were using to access the user's full name when our WindowNT was working.
Function GetUserName()
'************OLD NT CODE
objUserName = ""
If Request.ServerVariables("AUTH_USER") <> "" Then
strUserID = UCase(Request.ServerVariables("AUTH_USER"))
ElseIf Request.ServerVariables("LOGON_USER") <> "" Then
strUserID = UCase(Request.ServerVariables("LOGON_USER"))
End If
If strUserID <> "" Then
strDomain = "OURDOMAINNAME"
strUserID = Replace(strUserID, "\", "/")
strPath = "WinNT://" & strUserID
'NETSCAPE BROWSERS REQUIRE DOMAIN AS PART OF USER LOGIN
'SO IF THE DOMAIN IS ALREADY IN THE LOGIN
STRING, DO NOT ADD IT
if lcase(left(strUserID,6)) = "OURDOMAINNAME/" then
Set objUser = GetObject("WinNT://" & strUserID)
else
Set objUser = GetObject("WinNT://" & strDomain & "/" & strUserID)
end if
objUserName = objUser.FullName
'End If
GetUserName = objUserName
End Function
When we called this function with the Win2K Active Directory we get an error 'Permission Denied on GetObject'
I have been on many sites to figure out the code to retrieve the full name from Active Directory and it appears I may have to use
LDAP:// I am not familiar with this and have tried some code samples and contiually run into errors. i am sure because there are many factors I am not accountign for within
LDAP:// If anybody has any experience with this and could shed some light on the situation I would greatly appreciate it. I have temporarily put a bandaid on the situation so the time sheets are working for now but if i can come up with a real solution I will be the hero and people will carry me on their shoulders and I will demand Java for everyone.
Thanks