Ticket Q321056
Visible to All Users

Multi-Tennant Data

created 14 years ago

Hi,
I have 2 applications that require to be set-up with multi-tennant data. One is a new app from the ground up, the other will be based on the XCRM demo app - both supporting Domain Components. Both apps will only have a web UI.
Scenarios I need to accommodate are…
    When a user logs in:
        they will not select a company but will be logged into 'their' company
        they will only see information from their company.
        some classes *may* be shared across all companies
        some records may only be edited by the 'CreatedBy' user
        a user may not be logged in multiple times concurrently

The 'username' would preferably be an email address which is unique within the system
The way I see it, I will need 'Owner' (Company) and 'CreatedBy' (User) added to each class. These values would be filled in as each record is created based on the logged in user.
Filtering of views would occur by default based on the users company.
I notice in the 2011 RoadMap that a "a security system on the data layer level" is targeted for release in 2011 Vol 1 which I'm guessing will impact on what I would like to achieve. Is the Vol 1 release imminent and is it still likely to include the changes to the security system?
Can you please provide assistance with implementing the above scenario, either into XCRM or a clean project.
Best Regards,
Gavin Horne

Show previous comments (11)
DevExpress Support Team 14 years ago

    Hi Gavin,
    To accomplish this task, I recommend that you modify the IObjectOwner domain component to store a user instance (e.g. IPerson) in the CreatedBy property, instead of its key. Then, simply modify the list view filter criteria to compare user's organizations:
    CriteriaOperator.Parse("CreatedBy.Organization=?", View.ObjectSpace.GetObject(((IPerson)SecuritySystem.CurrentUser).Organization))
    >>>Is Domain Components the way to go if I have no intention on using anything other than XPO?
    The Domain Components technology is a different approach to design the business class model, with its exclusive features and limitations. It provides the functionality that cannot be implemented using persistent objects (the capability to create independent domain libraries and multiple inheritance), but hides some implementation details. So, you should decide whether you need these capabilities or a more detailed control over internal operation of your business objects.
    >>>Will performance be better, are there any other advantages?
    I am afraid DC won't show a higher performance than persistent object.
    Thanks,
    Michael.

      Michael,
      Thanks for all your help so far. I'm getting very close now to achieving my goals. Next, I would like to setup a "Company Admin" role. A user assigned to this role can add new users to their own Company and set the role(s) that user belongs to. I'm setting up a demo company admin as per the code below in Updater.cs but can't get the right object access levels. My Company Admin can add a new user but cannot link o roles. Can you please assit with the right "addpermission" code.
      Regards,
      Gavin
                  IPersistentRole companyadminRole = ObjectSpace.FindObject<IPersistentRole>(new BinaryOperator("Name", "Company Administrators"));
                  if (companyadminRole == null)
                  {
                      companyadminRole = ObjectSpace.CreateObject<IPersistentRole>();
                      companyadminRole.Name = "Company Administrators";
                  }
                  if (companyadminRole.ObjectAccessPermissions.Count == 0)
                  {
                      companyadminRole.AddPermission(typeof(IOrganization), ObjectAccess.Navigate);
                      companyadminRole.AddPermission(typeof(IOrganization), ObjectAccess.Read);
                      companyadminRole.AddPermission(typeof(IOrganization), ObjectAccess.Write);
                      companyadminRole.AddPermission(typeof(IMyAppUser), ObjectAccess.AllAccess);
                      companyadminRole.AddPermission(typeof(IPersistentRole), ObjectAccess.AllAccess);
                      companyadminRole.AddPermission(typeof(IObjectAccessPermission), ObjectAccess.Navigate);
                      companyadminRole.AddPermission(typeof(IObjectAccessPermission), ObjectAccess.Read);
                      companyadminRole.CanEditModel = false;
                  }

      DevExpress Support Team 14 years ago

        Hi Gavin,
        This issue has been recently reported to us: XCRM Demo: The IMyAppUser.UserName property editor is read-only. It is not related to the XCRM demo code, but to a bug in our framework. I am afraid there is no workaround in the current version. Please track issue B200191 to be notified when its status is changed.
        Thanks,
        Michael.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.