473,666 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can c# webpage read cookie placed by a batch job?

I've asked this on the asp ng, but couldn't get any advice, wondering if
anyone here can help...

GOAL: place a .NET cookie, in a user's cookie folder, containing the
machinename of the current machine the user is on. Then various .NET apps
will be able to compare a value in our db, and see if the user is allowed to
work on that machine.

So far, in the computers' startup routine (when the computer is logged
into), each computer writes the text to the appropriately named cookie file,
in that user's cookie folder. We've gotten this far.
The problem - .NET can't read it. I believe it has to do with hidden
characters. ie, take a look at a .NET
cookie. After the second 'e' in ClientInfoCooki e, there is a hidden
character. You'll notice it by spacing over, it spaces twice at that point.
Also, after 'localhost/' there's a hidden character, and before the first
'*' there's a hidden character. But the Echo command that the network
engineer is running, strips out hidden characters. Could this be why we
can't read the cookie?

Anyone have any experience doing what I'm trying to do? An easier way
perpaps. Maybe I can use a javascript cookie, and have the machine name &
currentuser placed in there. Can .NET read a JS cookie perhaps...

TY Jason Shohet

Nov 16 '05 #1
12 4604
If you are trying to prevent users from using specific workstations, why not
use the built-in Windows policy mechanism? That's what it's designed for.

Colin

"Jason Shohet" <__******@yahoo .com> wrote in message
news:eX******** ******@tk2msftn gp13.phx.gbl...
I've asked this on the asp ng, but couldn't get any advice, wondering if
anyone here can help...

GOAL: place a .NET cookie, in a user's cookie folder, containing the
machinename of the current machine the user is on. Then various .NET apps
will be able to compare a value in our db, and see if the user is allowed to work on that machine.

So far, in the computers' startup routine (when the computer is logged
into), each computer writes the text to the appropriately named cookie file, in that user's cookie folder. We've gotten this far.
The problem - .NET can't read it. I believe it has to do with hidden
characters. ie, take a look at a .NET
cookie. After the second 'e' in ClientInfoCooki e, there is a hidden
character. You'll notice it by spacing over, it spaces twice at that point. Also, after 'localhost/' there's a hidden character, and before the first
'*' there's a hidden character. But the Echo command that the network
engineer is running, strips out hidden characters. Could this be why we
can't read the cookie?

Anyone have any experience doing what I'm trying to do? An easier way
perpaps. Maybe I can use a javascript cookie, and have the machine name &
currentuser placed in there. Can .NET read a JS cookie perhaps...

TY Jason Shohet

Nov 16 '05 #2
N.K
Jason,

The correct way to get cookie and set cookie is use InternetSetCook ie
function and InternetSetCook ie function. If there is no expiry set for
cookie , cookie will become process level and if there is cookie will
stay in users cookie folder.

You need to use interop to call those Wininet functions.

[DllImport("wini net.dll", CharSet=CharSet .Auto, SetLastError=tr ue)]
public static extern bool InternetGetCook ie(
string lpszUrlName,
string lpszCookieName,
StringBuilder lpszCookieData,
[MarshalAs(Unman agedType.U4)]
ref int lpdwSize
);
[DllImport("wini net.dll", CharSet=CharSet .Auto, SetLastError=tr ue)]
public static extern bool InternetSetCook ie(
string lpszUrlName,
string lpszCookieName,
string lpszCookieData
);
Sample code to set a cookie ( persistant)
InternetSetCook ie(url,"Nirmal" ,"aaa;expire s = Sat, 01-Jan-2000
00:00:00 ");
I am not sure if this is what you want to acheive, Post if you need
more help.

Cheers
Nirmal
"Jason Shohet" <__******@yahoo .com> wrote in message news:<eX******* *******@tk2msft ngp13.phx.gbl>. ..
I've asked this on the asp ng, but couldn't get any advice, wondering if
anyone here can help...

GOAL: place a .NET cookie, in a user's cookie folder, containing the
machinename of the current machine the user is on. Then various .NET apps
will be able to compare a value in our db, and see if the user is allowed to
work on that machine.

So far, in the computers' startup routine (when the computer is logged
into), each computer writes the text to the appropriately named cookie file,
in that user's cookie folder. We've gotten this far.
The problem - .NET can't read it. I believe it has to do with hidden
characters. ie, take a look at a .NET
cookie. After the second 'e' in ClientInfoCooki e, there is a hidden
character. You'll notice it by spacing over, it spaces twice at that point.
Also, after 'localhost/' there's a hidden character, and before the first
'*' there's a hidden character. But the Echo command that the network
engineer is running, strips out hidden characters. Could this be why we
can't read the cookie?

Anyone have any experience doing what I'm trying to do? An easier way
perpaps. Maybe I can use a javascript cookie, and have the machine name &
currentuser placed in there. Can .NET read a JS cookie perhaps...

TY Jason Shohet

Nov 16 '05 #3

So you're talking about the startup routine when Windows loads up, it can
call Wininet functions? I've never seem what you're showing me below, but
I'm going to check if our guys can do it!!! Are you saying that
InternetSetCook ie ( ) can be called during the startup routine -- its not
DOS commands (like Echo etc) from a .Bat file is it? TY very much!!!
Nov 16 '05 #4
The network engineers refuse to turn on Netbios, and I believe thats
required to go after Active Directory (we're a total AD shop, everyone's got
windows 2000 etc).
Nov 16 '05 #5
hi. I'm digesting this now. What is the 'URL' parameter? What goes in
there.
Also, if I logon to the machine as shohetj, is that what goes into the
CookieName parameter?

my thinking is it goes like this:

InternetSetCook ie(url, "shohetj", "w2k-shohetj; expires = Sat, 01-Jan-2000
00:00:00");

Where shohetj is the cookiename, w2k-shohetj is my computer's machinename,
and url -- i have no idea! :)
TY for the help
Nov 16 '05 #6
Are you trying to prevent users from using any application on specific
machines, or just some specific browser-based applications from specific
machines? Maybe if you express your goal in terms of the actual goal,
instead of a solution you'll get a better solution. It seems to me that what
you should be doing is securing the individual workstations using the
existing mechanisms rather than trying to roll your own security solution.

Colin

"Jason Shohet" <__******@yahoo .com> wrote in message
news:e4******** ******@TK2MSFTN GP09.phx.gbl...
The network engineers refuse to turn on Netbios, and I believe thats
required to go after Active Directory (we're a total AD shop, everyone's got windows 2000 etc).

Nov 16 '05 #7
N.K
url is the url to which you need to set cookie. Cookies are generally
assigned against a domian and optionally path.

For eg, if you want to assign cookies which needs to be sent for
http://www.test.com

url = "http://www.test.com"
"Jason Shohet" <__******@yahoo .com> wrote in message news:<#o******* *******@TK2MSFT NGP11.phx.gbl>. ..
hi. I'm digesting this now. What is the 'URL' parameter? What goes in
there.
Also, if I logon to the machine as shohetj, is that what goes into the
CookieName parameter?

my thinking is it goes like this:

InternetSetCook ie(url, "shohetj", "w2k-shohetj; expires = Sat, 01-Jan-2000
00:00:00");

Where shohetj is the cookiename, w2k-shohetj is my computer's machinename,
and url -- i have no idea! :)
TY for the help

Nov 16 '05 #8
N.K
Though i am explaining you the way to set cookies, it will be much
better if you post your actual problem here as suggested already in
this thread...
Nov 16 '05 #9
Colin, NK,

Thank you for helping me muddle thru this. YES, I am trying to prevent
users from accessing 1 particular applicationm -- a Timekeeping ASP.NET
application, on any machine -- besides their own.

ie: Joe has permission to access his Timesheet from his workstation only.
Mary from her workstation only.

Tactic 1: we keep the workstation assigned to each user in our database.
So I know Joe can log onto Machine abc. Mary on def, lets say. A cookie
containing the machinename, is written everytime someone logs on to a
machine. Lets say Joe logs onto Mary's machine. A cookie will go into
Joe's cookie directory on Mary's machine and write def. When he attempts
to access the asp.net timesheet app, the app reads from the cookie. It sees
def. The app looks in the db and sees abc assigned to Joe, and he is
refused entry into the system!
NOTE: we're not worried about someone modifying the cookie file because the
users are on the intranet, they don't have access to their hard drives etc.

Tactic 2: validate directly against ActiveDirectory (we're a w2k shop)!
Unfort, Netbios is not enabled on our network due to fears of extra network
traffic by the head network engineer. FWIK, Netbios is req'd for this to
work.

Thanks for the help again! Jason Shohet

"Colin Young" <x@nospam.com > wrote in message
news:uV******** ******@tk2msftn gp13.phx.gbl...
Are you trying to prevent users from using any application on specific
machines, or just some specific browser-based applications from specific
machines? Maybe if you express your goal in terms of the actual goal,
instead of a solution you'll get a better solution. It seems to me that what you should be doing is securing the individual workstations using the
existing mechanisms rather than trying to roll your own security solution.

Colin

"Jason Shohet" <__******@yahoo .com> wrote in message
news:e4******** ******@TK2MSFTN GP09.phx.gbl...
The network engineers refuse to turn on Netbios, and I believe thats
required to go after Active Directory (we're a total AD shop, everyone's

got
windows 2000 etc).


Nov 16 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4252
by: Patrick | last post by:
I am trying to download the html page at http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1 Using the code public class DownloadWebPage { public static void main (String args) throws IOException { URL url = new
0
1131
by: mikelostcause | last post by:
Is there anyway to hold the base.WndProc(ref m) until after the Logout() finishes loading a webpage?? I'm working on shutting down an app that runs in the system tray, I have no problems shutting down, but I have problems saving data first. if the base.WndProc(ref m) is placed at the top, it closes, but the system does not continue to shutdown and it does not save the data via the Logout() funtion. If the base.WndProc(ref m) is placed...
1
1961
by: Stef | last post by:
Hi people, I have a problem with cookies set via javascript. What I try to achieve is, when a user comes on the intranet, he can click on a link ( a simple href) that will set the content to french or english. I want to set a cookie to persist that choice each time the user comes back on the intranet. This feature must be available everywhere on the intranet and the link is placed in an inner asp script called Menu.asp which is...
3
1212
by: Mike | last post by:
Hi, Upon login into my application I stored user data (userid, ...) in a cookie to be used throughout the application. One particular form is very complicated that uses AJAX and many AJAX postbacks it needs data from that cookie. Is it bad practice to keep opening that cookie to get data each request or should I store it (hidden fields ...)? In the future this application will be on multiple webservers (replicated with a load balancer...
6
2510
by: eureka | last post by:
Hi friends, I am developing a web application using Jsp and JS. I have a main Jsp page(Jsp1).Inside it I have an iframe having an Html- table which is created dynamically and contains all records from the backend-table . For creating this dynamic table I've used another Jsp(Jsp2) and in Jsp1 I say: <iframe id = "I1" src="Jsp2.jsp" width=320 scrolling="yes">
6
1450
by: Anton Vredegoor | last post by:
Since a few days I've been experimenting with a construct that enables me to send the sourcecode of the web page I'm reading through a Python script and then into a new tab in Mozilla. The new tab is automatically opened so the process feels very natural, although there's a lot of reading, filtering and writing behind the scene. I want to do three things with this post: A) Explain the process so that people can try it for themselves...
4
10600
by: fordie1000 | last post by:
Hi, I have been trying to do this for a few days now ... I'd appreciate any help or insights ... Basically I want to enter text into a web 'textarea' automatically ... here is what I thought I should have ... import urllib import urllib2 import cookielib
2
1611
by: miraan | last post by:
Hi, I set a php cookie on one page, is it possible to retrieve the same cookie on another webpage on my site or can i just retrieve the cookie from the page that i set the cookie on?
6
34444
by: Studlyami | last post by:
Hey all, I'm trying to create a simple (I think it should be simple) batch file. I want this file to open Internet Explorer 6 go to the webpage SIRIUS Satellite Radio - The Best Radio On Radio and run the javascript: launchPlayer(",",","); Is this possible? I don't know anything about batch files and i only got to the point where i can open the webpage, but i am unable to open it in IE. I tried START "C:\Program Files\Internet...
0
8863
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7378
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6189
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4358
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.