HighTechTalks DotNet Forums  

.net remoting server can't read file it should have access to read.

Dotnet Framework (Remoting) microsoft.public.dotnet.framework.remoting


Discuss .net remoting server can't read file it should have access to read. in the Dotnet Framework (Remoting) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
ceh
 
Posts: n/a

Default .net remoting server can't read file it should have access to read. - 11-16-2007 , 08:57 AM






Hi, I think I have a .net remoting permissions problem.

This is WinXP SP2

I have a .net ipc remoting client and server.
Each proc runs as the user who is logged in.

I add props to and set up my remoting as follows

IPC SERVER:

BinaryServerFormatterSinkProvider serverProv = new
BinaryServerFormatterSinkProvider();
serverProv.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilter Level.Full;

IDictionary props = new Hashtable();
props.Add("authorizedGroup", "Users");
props.Add("portName", Environment.MachineName);
props.Add("exclusiveAddressUse", false);

m_ipcChannel = new IpcServerChannel(props, serverProv);
ChannelServices.RegisterChannel(m_ipcChannel, false);

RemotingServices.Marshal(this, "IServer");


IPC CLIENT:

IChannel clientChannel = null;
IDictionary props = null;
string name = Constants.NAME_REMOTING_SERVER + "_CLIENT_CHANNEL";
uri = @"ipc://" + Environment.MachineName + "/IServer";

try
{
// Don't wait more than 2 seconds to connect
// Not sure what this does.
// If the server is not available, ie not running
// the function calls return immediately.
props = new Hashtable();
props.Add("name", name);
props.Add("connectionTimeout", 2000);
// this will only work in english, need to use
// LookupAccountSid for internationalization
props.Add("authorizedGroup", "Users");

if (null == ChannelServices.GetChannel(name))
{
clientChannel = new IpcClientChannel(props, null);
ChannelServices.RegisterChannel(clientChannel, false);
}
}

Now, if I log in as an admin, all is well.
If I log in as someone in the users group I have issues.
My assumption was "authorizedGroup", "Users" would allow users to
work.

The issue is that I need to read a file and when I'm not admin, I
don't have access.
The ntfs permissions are fine. That is, while logged in as a user, I
can read the file via notepad.
But the remoting processes don't have access to the file.

The client calls into the server who then reads the file to determine
an IP address.

It reports.

L 2007-11-16 09:39:25Z 5 readLineFromFile:0 0: Access to the path 'C:
\Program Files\company\product\Data\ip.dat' is denied.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
access, Int32 rights, Boolean useRights, FileShare share, Int32
bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at readLineFromFile(String file)


Can anyone help?

Thanks a million.

Reply With Quote
  #2  
Old   
ceh
 
Posts: n/a

Default Re: .net remoting server can't read file it should have access toread. - 11-16-2007 , 11:02 AM






I got this working, had to remote debug to figure it out.
Not sure why it failed.

The original method for reading the file was this.
TextReader tr = new StreamReader(new FileStream(file, FileMode.Open));

It is now this.
TextReader tr = new StreamReader(file);

Any idea why the first throws the exception?

I see in the .net docs for FileStream

"The constructor is given read/write access to the file, and it is
opened sharing Read access (that is, requests to open the file for
writing by this or another process will fail until the FileStream
object has been closed, but read attempts will succeed). The buffer
size is set to the default size of 4096 bytes (4 KB)."

Not sure why it states "constructor is given read/write" when I say
only open.
But that is probably the issue.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.