Win a copy of Programming with Types this week in the Angular and TypeScript forum
or The Design of Web APIs in the Web Services forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

ASP Question.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exact contents of the server variables collection depends upon the OS/Server you are using. I'm sure you have already tried this, but just in case, load this page to view what information is available.

If you tried that so long ago that the results are dusty, then you might look into the WMI SDK. It may help, and it may not. I don't know much about it except that I have seen some examples that lead me to believe that it may enable you to do what you are trying to do.
 
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On a slightly unrelated note... why does everyone use VBScript in their ASP when JScript is clearly a superior, simpler, more powerful, and easier to debug language? I guess I'm an official thread hijacker now.
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could be wrong, but isn't documentation for writing ASP in JScript hard to come by? I had to do a project at work in ASP before, but not knowing VB, I used JScript. Had a hell of a time finding any info on ASP using anything other than VBScript. I'm sure that's probably how MS wants it.
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everything is exactly the same if you write your ASP pages in VBScript or JScript or Perl or C#. The same global objects are available. The difference is purely mechanical. Plus my installation of PWS includes both VBScript and JScript documentation, so I assume they all do.
Microsoft probably does want everyone to use languages they designed themselves though. Not nice ones with built in regular expressions and object-oriented capabilities and clean bracketted syntax and uses beyond microsoft products (in EcmaScript or JavaScript form) and much more.
[ March 28, 2002: Message edited by: David Weitzman ]
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So Chris,
Do you have a CLUE how many heartattacks that you are causing in MO?
First you ask a REAL question in MD (naughty, naughty). And THEN it is about an unspeakable subject.
But then that was probably your ulterior motive all along - right? Bill sent you here to cause disruption and heartburn in the hopes that general pandamonium would insue.
We are on to your tactics Sir! Be forwarned
The rest of you don't know it, but I have it on good authority that Chris spends a good deal of his time in trenchcoats and sunglasses.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written ASP in JScript before. Actually, if you look at msdn you will be able to find ASP examples in JScript.
The reason that I don't do this much is that, it's not a good idea to invoke two scripting engines in the same page. It will slow performance tremendously. Since I usually am either maintaining, enhancing, or otherwise improving an existing product, I usually stick with the language they have chosen.
When I get to work on new initiatives, it's JScript, baby!
 
Chris Jackson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have only used VBScript in ASP pages. Not had much experience with JScript. Thankyou for the post hijack though . AS for giving out heart attacks, i understand, but what better place to come to then where I feel most comfortable, with Java peeps. Notice how I tossed in that I am SCJP. Anyway. I have gotten further and was forced to buy a book on Windows 2000 Active Directory Programming last night. Thrown right into LDAP://
Have come up with some new code that works to a point.
UName = ""
Set WshNetwork = CreateObject("WScript.Network")

UName = WshNetwork.UserName
Set objUser = GetObject("LDAP://OURSERVERNAME/DC=com/DC=OURDC/CN=Users/CN=" & UName)
Response.write objUser.Get("displayname")
Set objUser =nothing
Getting this error when i try to get the display name of the person.
The Active Directory datatype cannot be converted to/from a native DS datatype.
So if anybody knows about LDAP or what step I am missing, thanks.
 
Ranch Hand
Posts: 4702
9
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cindy,
actually i think meaningless drivel is the perfect place to discuss ASP
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Chris Jackson:
I have only used VBScript in ASP pages. Not had much experience with JScript. Thankyou for the post hijack though . AS for giving out heart attacks, i understand, but what better place to come to then where I feel most comfortable, with Java peeps. Notice how I tossed in that I am SCJP. Anyway. I have gotten further and was forced to buy a book on Windows 2000 Active Directory Programming last night. Thrown right into LDAP://
Have come up with some new code that works to a point.
UName = ""
Set WshNetwork = CreateObject("WScript.Network")

UName = WshNetwork.UserName
Set objUser = GetObject("LDAP://OURSERVERNAME/DC=com/DC=OURDC/CN=Users/CN=" & UName)
Response.write objUser.Get("displayname")
Set objUser =nothing
Getting this error when i try to get the display name of the person.
The Active Directory datatype cannot be converted to/from a native DS datatype.
So if anybody knows about LDAP or what step I am missing, thanks.

 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!