C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2722
Number of posts: 5749

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
LAN distribution Posted by viwufi on 1 Feb 2005 at 3:17 AM

I am developing an application in .net 2003 on a LAN.

Exe is distributed only on the server and the client
must make manually a shortcut of server application
in order to use it (that has a variety of benefits).

The problem is: When the application starts, how to
know from which IP or user name the shortcut is
executed?

example app:

class MainClass
{
	static void Main()
	{
		string userNameOrIpAddress = ???;
		Console.WriteLine( userNameOrIpAddress );
	}
}


When the server executes the app output is: TheServerName or 192.168.0.1
When the client executes the app output is: TheClientName or 192.168.0.2

Once again there is only one exe in the whole LAN (on the server)..


I would appreciate any help on this subject,
Thanks,
Report
Re: LAN distribution Posted by Baldusarius on 1 Feb 2005 at 9:56 AM
It sounds as if you are expecting the application to execute on the server just by placing it on the server. Unfortunately, that's not what happens. The application will be run on the client machine that invoked it. If you want the code to execute on the server, you should use .NET remoting or switch to a web-based app.

Anyway, you can get the user name from System.Environment.UserName property and the ip addresses (there can be more than one) from System.Net.Dns.Resolve(hostname).AddressList

:
: I am developing an application in .net 2003 on a LAN.
:
: Exe is distributed only on the server and the client
: must make manually a shortcut of server application
: in order to use it (that has a variety of benefits).
:
: The problem is: When the application starts, how to
: know from which IP or user name the shortcut is
: executed?
:
: example app:
:
:
: class MainClass
: {
: 	static void Main()
: 	{
: 		string userNameOrIpAddress = ???;
: 		Console.WriteLine( userNameOrIpAddress );
: 	}
: }
: 

:
: When the server executes the app output is: TheServerName or 192.168.0.1
: When the client executes the app output is: TheClientName or 192.168.0.2
:
: Once again there is only one exe in the whole LAN (on the server)..
:
:
: I would appreciate any help on this subject,
: Thanks,
:

Report
Re: LAN distribution Posted by viwufi on 1 Feb 2005 at 12:46 PM
Thank you for your reply.

I think that the key is in remoting. By now, i don't know much about it, but it 'smells' promising :)


BTW i know of Environment properties, that was my first guess
but it throws an permission exception of course, when the
app is executed on the client (actually a shortcut on the client
of the server app).

Report
Re: LAN distribution Posted by Baldusarius on 1 Feb 2005 at 1:28 PM
You mentioned an exception thrown when you checked local Environemt properties. You may already be aware of this, but .NET uses the concept of code access security (CAS) to determine what code should be allowed to run.

Code installed on the local machine has full permissions (NTFS and Windows permissions still apply, though), while intranet and internet code have reduced permissions, with internet code being the most restrictive. This is all configurable, of course. If you sign your assemblies with a string name, you can grant elevated permissions to assemblies with matching public keys.

You can read up on it here:

http://www.codeproject.com/dotnet/UB_CAS_NET.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/THCMCh08.asp

http://www.15seconds.com/issue/040121.htm

: Thank you for your reply.
:
: I think that the key is in remoting. By now, i don't know much about it, but it 'smells' promising :)
:
:
: BTW i know of Environment properties, that was my first guess
: but it throws an permission exception of course, when the
: app is executed on the client (actually a shortcut on the client
: of the server app).
:
:

Report
Re: LAN distribution Posted by viwufi on 2 Feb 2005 at 2:51 AM
!!!!!

for( int i = 0; i < 100; i++ )
Thanks();


:)




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.