Remoting Security .NET Framework 1.1

Posts   
 
    
reh
User
Posts: 5
Joined: 18-Mar-2005
# Posted on: 24-Mar-2005 18:17:00   

Hi

We created a remoted data layer on the IIS and can get entity classes from the client application via remoting.

Now we want send an entity back over the wire to the web server with no success.

We get always the following error message:

"Because of security restrictions, the type SD.LLBLGen.Pro.ORMSupportClasses.EntityFields2 cannot be accessed."

We saw special security issues for the .NET framework 1.1.

On this issues we added the following entries to our web.config: <channels> <channel ref="http"> <serverProviders> <provider ref="wsdl" /> <formatter ref="soap" typeFilterLevel="Full" /> <formatter ref="binary" typeFilterLevel="Full" /> </serverProviders> </channel> </channels>

How we can solve this problem?

Best regards

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 25-Mar-2005 12:53:28   

Does the code executing on the server have access to the ORMSupportLibrary? After making the changes for the type filter level attribute of the config file on the remote server did you bounce IIS?

reh
User
Posts: 5
Joined: 18-Mar-2005
# Posted on: 29-Mar-2005 10:09:37   

Hi

We tried both...but it isn't working. The Support-Lib is in the bin-Directory and the server should have access.. simple_smile

Are there other places where the security must be adjusted?

Regards renato

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 29-Mar-2005 17:44:27   

I think I might be confused about your scenario. Is this your scenario: You have a services object hosted in IIS that inherits from MarshalByRefObject. It has methods that can be called from the client that use LLBLGen pro objects in it's arguments and return types. The client can create an instance of an entity and pass it to a method in the services layer, but the services layer cannot return an instance of an entity object?

Does this describe your scenario?

reh
User
Posts: 5
Joined: 18-Mar-2005
# Posted on: 30-Mar-2005 09:02:43   

Yes, we have a service object which is hosted on a IIS an which is derived from MarshalByRefObject.

On the client we instantiate the service object as follows

IRemoteProvider rmPrv = (IRemoteProvider)Activator.GetObject(typeof(IRemoteProvider), ConfigurationSettings.AppSettings["wellknwonUrl"]);

then we call the following methods


LocationEntity loc = rmPrv.GetLocation(1); // Works
bool saveOk = rmPrv.SaveLocation(loc); // Security error occours

The GetLocation and SaveLocation methods are implemented as follows in the service class


public class RemoteProvider : MarshalByRefObject, IRemoteProvider
{
    private DataAccessAdapter m_Da;

    private DataAccessAdapter DaAp
    {
        get
        {
            if(m_Da==null)
            {
                m_Da = new DataAccessAdapter(ConfigurationSettings.AppSettings["dsn"]);
            }
            return m_Da;
        }
    }

    public LocationEntity GetLocation(int locationId)
    {
        LocationEntity loc = new LocationEntity();
        loc.LocationId = iLocId;
        this.Da.FetchEntity(loc);
        return loc;
    }

    public bool SaveLocation(LocationEntity loc)
    {
        bool retVal = false;
        if(loc != null)
        {               
            retVal = this.Da.SaveEntity(loc);
           this.Da.Commit();
        }
        return retVal;
    }
}

I hope this will explain our problem a bit better

reh
User
Posts: 5
Joined: 18-Mar-2005
# Posted on: 31-Mar-2005 07:42:56   

Frans found a topic in this forum which solved our problem:

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=321

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 01-Apr-2005 02:38:47   

According your config file, you were using typeFilterLevel=full on the server side. did you not have the same settings for the channel on the client side?

mdisbrow
User
Posts: 31
Joined: 22-Jun-2004
# Posted on: 03-Aug-2005 16:11:10   

What specifically fixed the problem? We have the same problem with a similar scenario and changing the config files (then bouncing IIS) to set the typeFilterLevel to 'Full' didn't solve the problem.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 03-Aug-2005 16:54:03   

mdisbrow wrote:

What specifically fixed the problem? We have the same problem with a similar scenario and changing the config files (then bouncing IIS) to set the typeFilterLevel to 'Full' didn't solve the problem.

You took a look at the MSDN article in that thread?

Frans Bouma | Lead developer LLBLGen Pro
mdisbrow
User
Posts: 31
Joined: 22-Jun-2004
# Posted on: 03-Aug-2005 17:11:55   

Yes, I've read the article in that thread and changed the configuration files accordingly (on the Web Server -- client and the Web Server hosting the remoted entities). No luck.

Brunello
User
Posts: 3
Joined: 09-Sep-2005
# Posted on: 09-Sep-2005 18:46:43   

I am having the same problem in a remoting scenario not using IIS.

I have an interface IOrganization :


public interface IOrganization
{
    bool SaveOrganization( OrganizationEntity org );
}

I have an implementation :


public class OrganizationImpl : MarshalByRefObject, IOrganization
{
    public bool SaveOrganization( OrganizationEntity org )
    {
        DataAccessAdapter adapter = new DataAccessAdapter( );
        return adapter.SaveEntity( org );
    }
}

The implementation is hosted in a service driven by the following config file

[code] <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="Main.ConnectionString" value="..." /> <add key="CatalogNameUsageSetting" value="1" /> <add key="CatalogNameToUse" value="ABSystemVII" /> </appSettings> <system.runtime.remoting> <application name="Application Server"> <service> <wellknown mode="SingleCall" type="Autobase.Organization.OrganizationImpl, LibOrganization" objectUri="OrganizationURI" /> </service> <channels> <channel ref="http" port="8686" /> <serverProviders> <formatter ref="soap" typeFilterLevel="Full" /> </serverProviders> </channels> </application> </system.runtime.remoting> </configuration> [/code/

On the client side we don't use config files but create the channel programatically:


channel = new HttpChannel( 0 );
ChannelServices.RegisterChannel( channel );

string objectUrl = "http://localhost:8686/OrganizationURI";
remotetype = new WellKnownClientTypeEntry(typeof(IOrganization), objectUrl );
RemotingConfiguration.RegisterWellKnownClientType(remotetype);
IOrganization organizationImpl = (IOrganization)Activator.GetObject( typeof (IOrganization), remotetype.ObjectUrl);

And then we call the save method

organizationImpl.SaveOrganization( someOrganitationEntity );

This results in the afformentioned security error.

I have read the MSDN note and have tried numerous variations on the information therein. I am pretty sure I am missing something stupid, but am tired of banging my head against the wall. Can anybody provide me a bit of assistance?

Thanks

Mike

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 10-Sep-2005 13:05:13   

I'm not a remoting guru, but perhaps this link can help you further: http://www.thinktecture.com/Resources/RemotingFAQ/Changes2003.html

Also searching on google groups with "Because of security restrictions" gives a lot of threads with the same error. You might find other hints there.

Frans Bouma | Lead developer LLBLGen Pro