dotnet remoting:
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.TypeFilterLevel.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?
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.
Don't see what you're looking for? Try a search.
|