# How to check user rights Rights and groups can be managed in the `Rechteverwaltung` module. The IDs for each user right can be found in `UserRightsConst.cs`. Always use these constants instead of the id itself. ## In viewmodels (Centron.WPF.UI) In viewmodels it's quite easy to check for user rights: ``` csharp CentronCache.Instance.CurrentUserAppRights.Any(f => f.I3D == UserRightsConst.T); ``` ## For modules Checking if an user has access to a module in `ModuleRegistration.cs` can be done via the first overload on: ``` csharp ModuleRegistrationItem.For(() => Helper.HasRights(UserRightsConst.T)) ``` ## In BL (Centron.BL) To check out user rights in BLs simply call `AppRightsBL.CheckRightsFromUser(currentUserI3D, your rightids)` then check if the result contains the necessary right. ``` csharp var checkRightsResult = new AppRightsBL(Session).CheckRightsFromUser(currentUserI3D, new List { UserRightsConst.Sales.Customer.CustomerCommon.CREATE_CUSTOMER, UserRightsConst.Sales.Customer.CustomerCommon.EDIT_CUSTOMER, UserRightsConst.Sales.Customer.CustomerCommon.DELETE_CUSTOMER, UserRightsConst.Sales.Customer.CustomerCommon.SEARCH_CUSTOMER, UserRightsConst.Sales.Customer.CustomerCommon.UNLOCK_CUSTOMER }); ``` Then check via: ``` csharp if (checkRightsResult.Contains(UserRightsConst.Sales.Customer.CustomerCommon.CREATE_CUSTOMER) == false) { return Result.AsError("Fehlende Rechte um Accounts zu erstellen"); } ``` (from `AccountBL.cs`)