当前位置: 首页>>代码示例>>C#>>正文


C# UserInfo.IsInRole方法代码示例

本文整理汇总了C#中DotNetNuke.Entities.Users.UserInfo.IsInRole方法的典型用法代码示例。如果您正苦于以下问题:C# UserInfo.IsInRole方法的具体用法?C# UserInfo.IsInRole怎么用?C# UserInfo.IsInRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotNetNuke.Entities.Users.UserInfo的用法示例。


在下文中一共展示了UserInfo.IsInRole方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: canUserAccessModule

        /// <param name="moduleId"></param>
        /// <param name="tabId"></param>
        /// <param name="permissionKey">You can use the constants, but for modules there are only
        /// those two</param>
        /// <returns></returns>
        public static bool canUserAccessModule(UserInfo user, int portalId, int tabId, ModuleInfo moduleInfo, string permissionKey)
        {
            var retVal = false;
            string permissionsString = null;
            if (moduleInfo.InheritViewPermissions)
            {
                var tabPermissionController = new TabPermissionController();
                var tabPermissionCollection =
                    tabPermissionController.GetTabPermissionsCollectionByTabID(tabId, portalId);
                permissionsString = tabPermissionController.GetTabPermissions(tabPermissionCollection, permissionKey);
            }
            else
            {
                var modulePermissionController = new ModulePermissionController();
                var permissionCollection =
                    modulePermissionController.GetModulePermissionsCollectionByModuleID(moduleInfo.ModuleID, tabId);
                permissionsString = modulePermissionController.GetModulePermissions(permissionCollection, permissionKey);
            }

            char[] splitter = { ';' };
            var roles = permissionsString.Split(splitter);
            foreach (var role in roles)
            {
                if (role.Length > 0)
                {
                    if (user != null && user.IsInRole(role))
                        retVal = true;
                    else if (user == null && role.ToLower().Equals("all users"))
                        retVal = true;
                }
                
            }
            return retVal;
        }
开发者ID:BravoSierra,项目名称:2sxc,代码行数:39,代码来源:SecurityContext.cs

示例2: UserIsInListOfRoles

        //returns true if user is in at least one role from a comma separated list of roles
        public bool UserIsInListOfRoles(UserInfo user, string listOfRoles)
        {
            bool result = false;

            string[] arrlistOfRoles = listOfRoles.Split(new char[] { ',' });
            foreach (string role in arrlistOfRoles)
            {
                if (user.IsInRole(role.Trim()))
                {
                    result = true;
                    break;
                }
            }

            return result;
        }
开发者ID:hriceto,项目名称:DNNFormsModule,代码行数:17,代码来源:CommonLogic.cs

示例3: CanUserViewTab

        /// <remarks>Source/Template from SecurityContext.canUserAccessModule()</remarks>
        private static bool CanUserViewTab(UserInfo user, int portalId, int tabId, string permissionKey = "VIEW")
        {
            //var retVal = false;
            var tabPermissionController = new TabPermissionController();
            var tabPermissionCollection = tabPermissionController.GetTabPermissionsCollectionByTabID(tabId, portalId);
            var permissionsString = tabPermissionController.GetTabPermissions(tabPermissionCollection, permissionKey);

            char[] splitter = { ';' };
            var roles = permissionsString.Split(splitter);

            foreach (var role in roles.Where(role => role.Length > 0))
            {
                if (user != null && user.IsInRole(role))
                    return true;
                if (role.ToLower().Equals("all users"))
                    return true;
            }

            return false;
        }
开发者ID:BravoSierra,项目名称:2sxc,代码行数:21,代码来源:Services.asmx.cs

示例4: ValidateLogin

 private static UserLoginStatus ValidateLogin(string username, string authType, UserInfo user,
                                              UserLoginStatus loginStatus, string password, ref bool bValid,
                                              int portalId)
 {
     if (loginStatus != UserLoginStatus.LOGIN_USERLOCKEDOUT &&
         (loginStatus != UserLoginStatus.LOGIN_USERNOTAPPROVED || user.IsInRole("Unverified Users")))
     {
         if (authType == "DNN")
         {
             if (user.IsSuperUser)
             {
                 if (ValidateUser(username, password))
                 {
                     loginStatus = UserLoginStatus.LOGIN_SUPERUSER;
                     bValid = true;
                 }
             }
             else
             {
                 if (ValidateUser(username, password))
                 {
                     loginStatus = UserLoginStatus.LOGIN_SUCCESS;
                     bValid = true;
                 }
             }
         }
         else
         {
             if (user.IsSuperUser)
             {
                 loginStatus = UserLoginStatus.LOGIN_SUPERUSER;
                 bValid = true;
             }
             else
             {
                 loginStatus = UserLoginStatus.LOGIN_SUCCESS;
                 bValid = true;
             }
         }
     }
     return loginStatus;
 }
开发者ID:revellado,项目名称:privateSocialGroups,代码行数:42,代码来源:AspNetMembershipProvider.cs

示例5: GetProperty

        public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo accessingUser, Scope accessLevel, ref bool propertyNotFound)
        {
            string retVal = "";
            switch (propertyName.ToLower())
            {
                case "all":
                    int moduleId = _moduleContext.ModuleId;
                    int portalId = _moduleContext.PortalId;
                    int tabId = _moduleContext.TabId;
                    ModuleInfo module = new ModuleController().GetModule(moduleId, tabId);

                    dynamic properties = new ExpandoObject();
                    System.IO.FileInfo fi = new System.IO.FileInfo(HttpContext.Current.Server.MapPath("~/" + _moduleContext.Configuration.ModuleControl.ControlSrc.Replace(".html", "") + ".resx"));
                    string physResourceFile = fi.DirectoryName + "/App_LocalResources/" + fi.Name;
                    string relResourceFile = "/DesktopModules/" + module.DesktopModule.FolderName + "/App_LocalResources/" + fi.Name;
                    if (File.Exists(physResourceFile))
                    {
                        using (var rsxr = new ResXResourceReader(physResourceFile))
                        {
                            var res = rsxr.OfType<DictionaryEntry>()
                                .ToDictionary(
                                    entry => entry.Key.ToString().Replace(".", "_"),
                                    entry => Localization.GetString(entry.Key.ToString(), relResourceFile));

                            properties.Resources = res;
                        }
                    }
                    else
                    {
                        properties.Resources = physResourceFile + " not found";
                    }
                    properties.Settings = _moduleContext.Settings;
                    properties.Editable = _moduleContext.EditMode && _moduleContext.IsEditable;
                    properties.Admin = accessingUser.IsInRole(PortalSettings.Current.AdministratorRoleName);
                    properties.ModuleId = moduleId;
                    properties.PortalId = portalId;
                    properties.UserId = accessingUser.UserID;
                    properties.HomeDirectory = PortalSettings.Current.HomeDirectory.Substring(1);
                    properties.RawUrl = HttpContext.Current.Request.RawUrl;

                    List<string> languages = new List<string>();
                    LocaleController lc = new LocaleController();
                    Dictionary<string, Locale> loc = lc.GetLocales(_moduleContext.PortalId);
                    foreach (KeyValuePair<string, Locale> item in loc)
                    {
                        string cultureCode = item.Value.Culture.Name;
                        languages.Add(cultureCode);
                    }
                    properties.Languages = languages;
                    properties.CurrentLanguage = System.Threading.Thread.CurrentThread.CurrentCulture.Name;

                    retVal = JsonConvert.SerializeObject(properties);
                    break;
                case "view":
                    retVal = (string)_moduleContext.Settings["View"];
                    if (String.IsNullOrEmpty(retVal))
                        retVal = "View.html";
                    break;
                case "list":
                    retVal = (string)_moduleContext.Settings["List"];
                    if (String.IsNullOrEmpty(retVal))
                        retVal = "List.html";
                    break;
            }
            return retVal;

        }
开发者ID:weggetor,项目名称:BBImageStory,代码行数:67,代码来源:BusinessController.cs

示例6: CheckAccessLevel

        private bool CheckAccessLevel(ProfilePropertyDefinition property, UserInfo accessingUser)
        {
            var isAdminUser = IsAdminUser(accessingUser);

            //Use properties visible property but admins and hosts can always see the property
            var isVisible = property.Visible || isAdminUser;

            if (isVisible && !isAdminUser)
            {
                switch (property.ProfileVisibility.VisibilityMode)
                {
                    case UserVisibilityMode.FriendsAndGroups:
                        isVisible = IsUser(accessingUser);
                        if(!isVisible)
                        {
                            //Relationships
                            foreach (Relationship relationship in property.ProfileVisibility.RelationshipVisibilities)
                            {
                                if (user.Social.UserRelationships.Any(userRelationship =>
                                                                          (userRelationship.RelationshipId == relationship.RelationshipId
                                                                              && accessingUser.UserID == userRelationship.RelatedUserId)
                                                                      ))
                                {
                                    isVisible = true;
                                    break;
                                }
                            }
                            //Groups/Roles
                            if (property.ProfileVisibility.RoleVisibilities.Any(role => accessingUser.IsInRole(role.RoleName)))
                            {
                                isVisible = true;
                            }
                        }
                        break;
                    case UserVisibilityMode.AllUsers:
                        // property is visible to everyone so do nothing
                        break;
                    case UserVisibilityMode.MembersOnly:
                        // property visible if accessing user is a member
                        isVisible = IsMember(accessingUser);
                        break;
                    case UserVisibilityMode.AdminOnly:
                        //accessing user not admin user so property is hidden (unless it is the user him/herself)
                        isVisible = IsUser(accessingUser);
                        break;
                }               
            }

            return isVisible;
        }
开发者ID:rut5949,项目名称:Dnn.Platform,代码行数:50,代码来源:ProfilePropertyAccess.cs

示例7: IsAdminUser

        private bool IsAdminUser(UserInfo accessingUser)
        {
            bool isAdmin = false;

            if (accessingUser != null)
            {
                //Is Super User?
                isAdmin = accessingUser.IsSuperUser;

                if (!isAdmin && user.PortalID != -1)
                {
                    //Is Administrator
                    if (String.IsNullOrEmpty(administratorRoleName))
                    {
                        PortalInfo ps = new PortalController().GetPortal(user.PortalID);
                        administratorRoleName = ps.AdministratorRoleName;
                    }

                    isAdmin = accessingUser.IsInRole(administratorRoleName);
                }
            }

            return isAdmin;
        }
开发者ID:rut5949,项目名称:Dnn.Platform,代码行数:24,代码来源:ProfilePropertyAccess.cs

示例8: IsInRoles

        public static bool IsInRoles(UserInfo objUserInfo, PortalSettings settings, string roles)
        {
            //super user always has full access
            bool isInRoles = objUserInfo.IsSuperUser;

            if (!isInRoles)
            {
                if (roles != null)
                {
                    //permissions strings are encoded with Deny permissions at the beginning and Grant permissions at the end for optimal performance
                    foreach (string role in roles.Split(new[] { ';' }))
                    {
                        if (!String.IsNullOrEmpty(role))
                        {
                            //Deny permission
                            if (role.StartsWith("!"))
                            {
                                //Portal Admin cannot be denied from his/her portal (so ignore deny permissions if user is portal admin)
                                if (!(settings.PortalId == objUserInfo.PortalID && settings.AdministratorId == objUserInfo.UserID))
                                {
                                    string denyRole = role.Replace("!", "");
                                    if (denyRole == Globals.glbRoleAllUsersName || objUserInfo.IsInRole(denyRole))
                                    {
                                        break;
                                    }
                                }
                            }
                            else //Grant permission
                            {
                                if (role == Globals.glbRoleAllUsersName || objUserInfo.IsInRole(role))
                                {
                                    isInRoles = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            return isInRoles;
        }
开发者ID:hungnt-me,项目名称:Dnn.Platform,代码行数:41,代码来源:PortalSecurity.cs

示例9: IsAdminOrHost

 internal virtual bool IsAdminOrHost(UserInfo userInfo)
 {
     return userInfo.IsSuperUser || userInfo.IsInRole(TestablePortalSettings.Instance.AdministratorRoleName);
 }
开发者ID:biganth,项目名称:Curt,代码行数:4,代码来源:MessagingControllerImpl.cs

示例10: ValidateRoles

        /// <summary>
        /// Validates the roles.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="feedObj">The feed obj.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        private bool ValidateRoles(UserInfo user, Feed feedObj)
        {
            if(feedObj.Roles!="" && !user.IsSuperUser && !user.IsInRole("Administrators"))
            {
                bool isValid = false;
                foreach (string s in  feedObj.Roles.Split(','))
                {
                    if(user.IsInRole(s.Trim()) || s.Trim()=="All Users")
                    {
                        isValid = true;
                        break;
                    }

                }
                return isValid;
            }

            return true;
        }
开发者ID:jsheely,项目名称:DotNetNuke-Data-Expose,代码行数:25,代码来源:ServicesController.cs

示例11: PopulateClientData

        private void PopulateClientData(int userId)
        {
            _clientInfo = new NBrightInfo(true);
            _clientInfo.ItemID = userId;
            _clientInfo.UserId = userId;
            _clientInfo.PortalId = PortalId;

            _userInfo = UserController.GetUserById(PortalId, userId);
            if (_userInfo != null)
            {
                Exists = true;

                _clientInfo.ModifiedDate = _userInfo.Membership.CreatedDate;

                foreach (var propertyInfo in _userInfo.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        var pv = propertyInfo.GetValue(_userInfo, null);
                        if (pv == null) pv = "";
                        _clientInfo.SetXmlProperty("genxml/textbox/" + propertyInfo.Name.ToLower(), pv.ToString());
                    }
                }

                foreach (DotNetNuke.Entities.Profile.ProfilePropertyDefinition p in _userInfo.Profile.ProfileProperties)
                {
                    _clientInfo.SetXmlProperty("genxml/textbox/" + p.PropertyName.ToLower(), p.PropertyValue);
                }

                _clientInfo.AddSingleNode("membership", "", "genxml");
                foreach (var propertyInfo in _userInfo.Membership.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        var pv = propertyInfo.GetValue(_userInfo.Membership, null);
                        if (pv != null) _clientInfo.SetXmlProperty("genxml/membership/" + propertyInfo.Name.ToLower(), pv.ToString());
                    }
                }

                if (_userInfo.IsInRole(StoreSettings.ClientEditorRole))
                {
                    _clientInfo.SetXmlProperty("genxml/checkbox/clienteditorrole", "True");
                }
                else
                {
                    _clientInfo.SetXmlProperty("genxml/checkbox/clienteditorrole", "False");
                }

                var objCtrl = new NBrightBuyController();
                DataRecord = objCtrl.GetByType(PortalId, -1, "CLIENT", _userInfo.UserID.ToString(""));
                if (DataRecord == null)
                {
                    DataRecord = new NBrightInfo(true);
                    DataRecord.ItemID = -1;
                    DataRecord.UserId = _userInfo.UserID;
                    DataRecord.PortalId = PortalId;
                    DataRecord.ModuleId = -1;
                    DataRecord.TypeCode = "CLIENT";
                }
                DiscountCodes = GetEntityList("discountcodes");
                VoucherCodes = GetEntityList("vouchercodes");

            }
        }
开发者ID:DNNMonster,项目名称:NBrightBuy,代码行数:64,代码来源:ClientData.cs

示例12: ProcessSecurityRole

 private static void ProcessSecurityRole(UserInfo user, PortalSettings settings, string roleName, out bool? roleAllowed)
 {
     roleAllowed = null;
     //permissions strings are encoded with Deny permissions at the beginning and Grant permissions at the end for optimal performance
     if (!String.IsNullOrEmpty(roleName))
     {
         //Deny permission
         if (roleName.StartsWith("!"))
         {
             //Portal Admin cannot be denied from his/her portal (so ignore deny permissions if user is portal admin)
             if (settings != null && !(settings.PortalId == user.PortalID && settings.AdministratorId == user.UserID))
             {
                 string denyRole = roleName.Replace("!", "");
                 if (denyRole == Globals.glbRoleAllUsersName || user.IsInRole(denyRole))
                 {
                     roleAllowed = false;
                 }
             }
         }
         else //Grant permission
         {
             if (roleName == Globals.glbRoleAllUsersName || user.IsInRole(roleName))
             {
                 roleAllowed = true;
             }
         }
     }            
 }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:28,代码来源:PortalSecurity.cs

示例13: DisplayOrderData

        private void DisplayOrderData(int portalId, UserInfo userInfo, String entryId)
        {
            var strOut = "***ERROR***  Invalid Data";
            if (Utils.IsNumeric(entryId) && entryId != "0")
            {
                var orderData = new OrderData(portalId, Convert.ToInt32(entryId));
                if (orderData.PurchaseInfo.TypeCode == "ORDER")
                {
                    strOut = "***ERROR***  Invalid Security";
                    if (_scode == orderData.PurchaseInfo.GetXmlProperty("genxml/securitycode") || userInfo.UserID == orderData.UserId || userInfo.IsInRole(StoreSettings.ManagerRole) || userInfo.IsInRole(StoreSettings.EditorRole))
                    {
                        //check the payment provider for a print url
                        var shippingprovider = orderData.PurchaseInfo.GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/shippingprovider");
                        if (shippingprovider != "")
                        {
                            var shipprov = ShippingInterface.Instance(shippingprovider);
                            if (shipprov != null)
                            {
                                if (_printtype == "shiplabel")
                                {
                                    var printurl = shipprov.GetDeliveryLabelUrl(orderData.PurchaseInfo);
                                    if (printurl != "") Response.Redirect(printurl);
                                }
                            }
                        }

                        // No print label, so print template specified.
                        var obj = new NBrightInfo(true);
                        obj.PortalId = PortalSettings.Current.PortalId;
                        obj.ModuleId = 0;
                        obj.Lang = Utils.GetCurrentCulture();
                        obj.GUIDKey = _printtype;
                        obj.ItemID = -1;

                        strOut = NBrightBuyUtils.RazorTemplRender("printorder.cshtml", 0, "", obj, "/DesktopModules/NBright/NBrightBuy", _theme, Utils.GetCurrentCulture(), StoreSettings.Current.Settings());
                    }
                }
            }
            var l = new Literal();
            l.Text = strOut;
            phData.Controls.Add(l);
        }
开发者ID:DNNMonster,项目名称:NBrightBuy,代码行数:42,代码来源:PrintView.aspx.cs

示例14: IsInSexyContentDesignersGroup

 /// <summary>
 /// Returns true if a user is in the SexyContent Designers group
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public static bool IsInSexyContentDesignersGroup(UserInfo user)
 {
     return user.IsInRole(SexyContentGroupName);
 }
开发者ID:BravoSierra,项目名称:2sxc,代码行数:9,代码来源:SexyContent.cs

示例15: IsAdminOrHost

 internal virtual bool IsAdminOrHost(UserInfo userInfo)
 {
     return userInfo.IsSuperUser || userInfo.IsInRole(PortalController.Instance.GetCurrentPortalSettings().AdministratorRoleName);
 }
开发者ID:rjallepalli,项目名称:PIX_CMS,代码行数:4,代码来源:InternalMessagingControllerImpl.cs


注:本文中的DotNetNuke.Entities.Users.UserInfo.IsInRole方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。