コード例 #1
0
        public IEnumerable <string> GetRoles()
        {
            //FOR WINDOWS AUTHENTICATION....
            var UseActiveDirectory = System.Configuration.ConfigurationManager.AppSettings["UseActiveDirectory"]; //CommonFunction.Instance.UseActiveDirectory();

            if (Convert.ToBoolean(UseActiveDirectory))
            {
                //var adl = new ActiveDirectoryLookup(this.Identity);
                //return adl.GetRoles();
                var UseActiveDirectoryRole = System.Configuration.ConfigurationManager.AppSettings["UseActiveDirectoryRole"];
                if (Convert.ToBoolean(UseActiveDirectoryRole))
                {
                    var adl = new ActiveDirectoryLookup(this.Identity);
                    return(adl.GetRoles());
                }
                else
                {
                    var DomainName = System.Configuration.ConfigurationManager.AppSettings["DomainName"];
                    CustomRoleProvider RoleProvider = new CustomRoleProvider();
                    string             usrname      = this.Name.Replace(DomainName.ToUpper() + "\\", "").Trim();
                    return(RoleProvider.GetRolesForUser(usrname));
                }
            }
            else
            {
                CustomRoleProvider RoleProvider = new CustomRoleProvider();
                return(RoleProvider.GetRolesForUser(((IIdentity)this.Identity).Name));
            }
        }
コード例 #2
0
ファイル: ApiUser.cs プロジェクト: shwetasakrikar/hops_hr_v18
        public IEnumerable <string> GetRoles()
        {
            CustomRoleProvider RoleProvider = new CustomRoleProvider();

            return(RoleProvider.GetRolesForUser(this.Name));
        }