Reference a VBScript Variable in ASP

B

BP Prgm

This is my VBScript function:

<script language="JavaScript" type="text/JavaScript">
Dim UN
Set objNet = CreateObject("WScript.NetWork")
Set objUser = GetObject("WinNT://my domain/" & objNet.UserName )
UN = objNet.UserName & " (" & objUser.FullName & ")"
</script>

How can I reference the VBScript Variable UN in my ASP code?
<%=UN%> won't work because VBScript is on the client side and ASP is on the
server side

If I have to post it on one page and read it on another, how do I do that?
I'm somewhat new to ASP...

Thanks!
 
B

Bob Barrows

BP said:
This is my VBScript function:

<script language="JavaScript" type="text/JavaScript">
Dim UN
Set objNet = CreateObject("WScript.NetWork")
Set objUser = GetObject("WinNT://my domain/" & objNet.UserName )
UN = objNet.UserName & " (" & objUser.FullName & ")"
</script>

How can I reference the VBScript Variable UN in my ASP code?
<%=UN%> won't work because VBScript is on the client side and ASP is
on the server side

If I have to post it on one page and read it on another, how do I do
that? I'm somewhat new to ASP...

Well, you could do this:

<form id = frmLogin action="somepage.asp" method="post>
<input type=text style="visibility:hidden" id=txtLogin>
</form>
<script language="JavaScript" type="text/JavaScript">
Dim UN
Set objNet = CreateObject("WScript.NetWork")
Set objUser = GetObject("WinNT://my domain/" & objNet.UserName )
UN = objNet.UserName & " (" & objUser.FullName & ")"
frmLogin.txtLogin.value = UN
frmLogin.submit
</script>

And in somepage.asp:

<%
user = Request.Form("txtLogin")
%>

But, why bother? Use IIS Manager to configure your site to use Windows
Authentication and turn off Anonymous access. Then in ASP, use

user=Request.servervariables("LOGIN_USER")

to get the fully qualified login name of the user.

HTH,
Bob Barrows
 
B

BP Prgm

I have used that, but I want to get some other items like the user's full
name and computer name. Is there a way I can conversely use ASP variables in
VBScript? That way I can put everything on one page and just use the
user=Request.servervariables("LOGIN_USER") to get the other info with
VBScript.
 
B

Bob Barrows

In our Intranet, I have found that I am SOMETIMES able to get the computer
name via "REMOTE_NAME". Sometimes this servervariable only contains the ip
address of the machine - no idea why.

Bob
 
D

dlbjr

This is my VBScript function:

<script language="JavaScript" type="text/JavaScript">
Dim UN
Set objNet = CreateObject("WScript.NetWork")
Set objUser = GetObject("WinNT://my domain/" & objNet.UserName )
UN = objNet.UserName & " (" & objUser.FullName & ")"
</script>

This would never run do to the language="JavaScript" with
VBScript Syntax embedded.
--
-------------------------------------------------
d l b j r

Unambit from meager knowledge of inane others,
engender uncharted sagacity.
-------------------------------------------------
 
B

Bob Barrows

dlbjr said:
This is my VBScript function:

<script language="JavaScript" type="text/JavaScript">
Dim UN
Set objNet = CreateObject("WScript.NetWork")
Set objUser = GetObject("WinNT://my domain/" & objNet.UserName )
UN = objNet.UserName & " (" & objUser.FullName & ")"
</script>

This would never run do to the language="JavaScript" with
VBScript Syntax embedded.

?
What does that have to do with my post? You DID reply to me.
Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top