473,218 Members | 1,824 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,218 software developers and data experts.

windows username to ms access

28
hi,

I'm trying to pull the windows username with jscript and save it to ms access field in a table, but it does not work. it does show the alert with the name of the user but does not save it to the ms access field. here i steh code that i'm using. please help

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT type=text/javascript>
  2. <!--
  3. var WinNetwork = new ActiveXObject("WScript.Network");  
  4. alert(WinNetwork.userName);
  5.  
  6. var adOpenDynamic = 2;
  7. var adLockOptimistic = 3;
  8.  
  9. /* Path of database.
  10. */
  11. var strDbPath = "C:\Documents and Settings\ASPIRE\Desktop\ss1 upgrade\SS1\db1";
  12.  
  13. /*
  14. Here is the ConnectionString for Microsoft Access.
  15.  
  16. */
  17. var conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDbPath;
  18.  
  19. function AddRecord() {
  20. var adoConn = new ActiveXObject("ADODB.Connection");
  21. var adoRS = new ActiveXObject("ADODB.Recordset");
  22.  
  23. adoConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='\\db1.mdb'");
  24. adoRS.Open("Select * From TimeTrackerTable Where Group = 'xxxx'", adoConn, 1, 3);
  25.  
  26. adoRS.AddNew;
  27. adoRS.Fields("Group").value = "(WinNetwork.userName)";
  28. adoRS.Update;
  29.  
  30. adoRS.Close();
  31. adoConn.Close();
  32. }
  33.  
  34.  
  35. function getAdoDb(strAdoType){
  36. if (window.ActiveXObject){
  37. return new ActiveXObject(strAdoType);
  38. }
  39. else{
  40. return ActiveXObject(strAdoType);
  41. }
  42. }
  43. </SCRIPT>
  44.  <INPUT id=Button1 onclick=EditRecord() type=button name=Command0 ;><BR>
  45. <SCRIPT language=javascript event=onclick for=Command0>
  46. try { if (MSODSC.DataPages.Count > 0)
  47. if (MSODSC.CurrentSection == null)
  48.     MSODSC.DataPages(0).Save();
  49. else
  50.     MSODSC.CurrentSection.DataPage.Save(); }    
  51. catch (e)
  52. { alert (e.description);}
  53. </SCRIPT>
  54.  
Regards,
xx
Sep 23 '08 #1
4 4150
pronerd
392 Expert 256MB
This is really more of an ActiveX question than a JavaScript one so you may want to try a forum that covers that.

I do see a number of issues, but I do not know if any of them are the problem.

First off the alert is being called because it is in the catch block. Some exception is being thrown causing the field value to not be set and causing the code in the catch block to execute instead.

Secondly the attributes in your HTML tags need to be surrounded by quotes. Third there is a semicolon in your input tag that should not be there.

The tags should look like this:
Expand|Select|Wrap|Line Numbers
  1. <SCRIPT type="text/javascript">
Expand|Select|Wrap|Line Numbers
  1. <INPUT id="Button1" onclick="EditRecord()" type="button" name="Command0" />
Fouth the line below has a number of problems. All the attribute values need quotes. I do not see "event" or "for" as valid attributes for the script tag in any DOM documentation. Even if they are in IE how would you ever have an onclick event on a script tag. It is not rendered on the page and can not be clicked on.
Expand|Select|Wrap|Line Numbers
  1. <SCRIPT language=javascript event=onclick for=Command0>
Last but not lest what you are trying to do is ex termly unsafe. I would be very surprised if IE will let you run this code by default even in the local zone. So you will probably have to lower your IE security setting all the way for this code to run.
Sep 23 '08 #2
orajat
28
security would not be a concern, the only problem i see is in line 27.....
Sep 25 '08 #3
pronerd
392 Expert 256MB
security would not be a concern,
It may not be a concern, but it is a problem. It is very unlikely that IE will let you do direct local system access in the default security settings. You will have to lower your security settings to the lowest point to be able to do local system access like this.



the only problem i see is in line 27.....
And you are basing that on what? Line 17 is not even inside the try catch block where the exception is being thrown. For that matter I do not even see where the function for the code on line 27 is called. What is calling the getAdoDb() function?
Sep 25 '08 #4
orajat
28
by problem i meant that the whole excercise is to save the windows username in the ms access field, which is not hapenning....

xx

It may not be a concern, but it is a problem. It is very unlikely that IE will let you do direct local system access in the default security settings. You will have to lower your security settings to the lowest point to be able to do local system access like this.




And you are basing that on what? Line 17 is not even inside the try catch block where the exception is being thrown. For that matter I do not even see where the function for the code on line 27 is called. What is calling the getAdoDb() function?
Sep 26 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Newbie | last post by:
I am a newsbie to ASP but need to get a script together that will insert the Windows Username of the local machine into an access database. I get the errors from my code below, can anyone help me...
2
by: Joseph Geretz | last post by:
I'm having a credentialing problem in my web application. Actually, I don't think this is an IIS security issue, since I'm able to access the page I'm requesting. However, the executing page itself...
8
by: Jonathan Dixon | last post by:
I am developing an intranet and was wondering, when a user logs on is there a way to get the username of the windows account in asp.net. I have tried the following but they return the worker...
5
by: pberna | last post by:
Dear all, I built a Web Form application to start and stop a Windows Service remotely. I successful tested the application on Windows 2000 server + IIS. I must include the ASPNET user to the...
8
by: Raj Thakkar | last post by:
Hi, I am currenty working on a site for intranet. I have a user control in the header of every page that will be displayed only if people with certain username are surfing the site. These lists...
6
by: John Dalberg | last post by:
I want to automate the process of logging into an intranet. I want to pull out the username of the Windows user logged into the machine running the browser and use the username in my app. How can I...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
1
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
7
by: Alice Wong | last post by:
I am setting up my Web ASP.net application to connect to Sql server using windows authentication. I set up IIS to have integrated windows authenication and sql to allow Windows authentication....
4
by: =?Utf-8?B?QXZhRGV2?= | last post by:
ASP.Net 2. We are migrating to Windows 2008 64 bit Server with IIS 7 from Windows 2003 32 Bit with IIS 6. A few library classes we wrote uses impersonation in code like explained in this...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.