Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting windows user name from data access page

Status
Not open for further replies.

DanielGreenwood

Technical User
May 9, 2002
21
0
0
GB
Hi,

I'm developing an internal system using data access pages to view data stored on Access 2003. In order for the users to only see the data relevent to them i would like to filter based on their login name.

I have found it's not possible to do this using a database login therefore need to grab the windows ID. I found this code to get the ID:

Code:
<SCRIPT language=VBScript>
Dim objNet
On Error Resume Next 'If fail to create object then display error
' (press no message)
Set objNet = CreateObject("WScript.NetWork")
If Err.Number <> 0 Then 'If err
MsgBox err.number & " " & err.Description
'Document.Location = "test2.html" 'Display document by placing name again
End if

Dim strInfo
strInfo = "User Name is " & objNet.UserName & vbCRLF & _
"Computer Name is " & objNet.ComputerName & vbCRLF & _
"Domain Name is " & objNet.UserDomain

txtUserName.value = strInfo


Set objNet = Nothing 'Destroy the Object

</Script>


This code works when i run it as stand alone htm but gives the 429 error 'ActiveX cannot creat the object'.

Does anyone have any idea why this won't work when in a data access page or another way of getting the windows user name?

I'd be grateful for your help.
 
I have used a textbox with a source =Environ("UserName"). This textbox is not visible. Then use it to filter who can see what. It keeps honest people honest.
 
Do you use this method with data access page?

I know this works on forms but I cannot set the control source to this value on a text box in data access page. It gives me an error 'invalid 'condition'
 
To be honest have never tried. We use an old version of Access (97).
 
I would use the API call rather than Environ("UserName") in an MDB.

For pages, you might want to try
Code:
   Request.ServerVariables("AUTH_USER")
I use this with ASP pages to return the DOMAIN\LOGIN.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top