本文整理汇总了C#中System.Security.Permissions.PrincipalPermission.Demand方法的典型用法代码示例。如果您正苦于以下问题:C# PrincipalPermission.Demand方法的具体用法?C# PrincipalPermission.Demand怎么用?C# PrincipalPermission.Demand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Permissions.PrincipalPermission
的用法示例。
在下文中一共展示了PrincipalPermission.Demand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
SetDefaultControls("btnGetRight", "");
PrincipalPermission permReg = new PrincipalPermission(Context.User.Identity.Name, "Registered");
permReg.Demand();
if (!Page.IsPostBack)
{
IOrganisationService srvOrg = ServiceFactory.GetOrganisationService();
//megnézzük hogy volt e szervezet kiválasztva (van e selectedOrgId)
string selectedOrgId = Request["selectedOrgId"];
if (selectedOrgId != null)
{
//lekérdezzük a kiválasztott szervezet adatait
Organisation org = srvOrg.OrganisationSelect(new Guid(selectedOrgId));
txtOrgInstitution.Text = org.Name;
lblZipCode.Text = org.PostCode;
lblTownShip.Text = org.City;
lblAddress.Text = org.Address;
lblOrganisationForm.Text = org.Department.IsNull ? "-" : org.Department.ToString();
}
}
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
// Put user code to initialize the page here
// Check permission: all registered user
PrincipalPermission perm = new PrincipalPermission(Context.User.Identity.Name, "Registered");
perm.Demand();
}
示例3: EDocumentCommendationDelete
public new void EDocumentCommendationDelete(EDocumentCommendation entity)
{
// check permission: admin
PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
permAdmin.Demand();
TraceCallEnterEvent.Raise();
try
{
base.EDocumentCommendationDelete(entity);
BusinessAuditEvent.Success();
TraceCallReturnEvent.Raise();
return;
}
catch (Exception ex)
{
ExceptionManager.Publish(ex);
BusinessAuditEvent.Fail(
new EventParameter("Exception", ex.ToString())
);
TraceCallReturnEvent.Raise(false);
throw;
}
}
示例4: OfficerMethod
public static void OfficerMethod()
{
string name = "��";
string role = "ʿ��";
PrincipalPermission principalPermission = new PrincipalPermission(name, role);
principalPermission.Demand();
}
示例5: NewsPictureDelete
public new void NewsPictureDelete(NewsPicture entity)
{
// check permission: admin
PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
permAdmin.Demand();
TraceCallEnterEvent.Raise();
try
{
FileDataContext fileDataContext = new FileDataContext();
string ext = Path.GetExtension(entity.PictureUrl).ToLower();
string fileName = entity.ID.ToString() + ext;
fileDataContext.NewsPictureDelete(entity.NewsRef, fileName);
base.NewsPictureDelete(entity);
BusinessAuditEvent.Success();
TraceCallReturnEvent.Raise();
return;
}
catch (Exception ex)
{
ExceptionManager.Publish(ex);
BusinessAuditEvent.Fail(
new EventParameter("Exception", ex.ToString())
);
TraceCallReturnEvent.Raise(false);
throw;
}
}
示例6: EmailSelectFiltered
public EmailContainer EmailSelectFiltered(Email filter)
{
// Check permission: admin
PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
permAdmin.Demand();
TraceCallEnterEvent.Raise();
try
{
EmailContainer result;
DataSet entitySet = m_DataContext.ndihdEmailSelectFiltered(
filter.Category,
filter.FilterOnSentFrom,
filter.FilterOnSentTo,
filter.FilterOnActivityPrevention,
filter.FilterOnActivityResearch,
filter.FilterOnActivityRehabilitation,
filter.FilterOnActivityOther,
filter.FilterOnNDI,
filter.FilterOnActivityAll
);
result = new EmailContainer(entitySet.Tables[0]);
TraceCallReturnEvent.Raise();
return result;
}
catch (Exception ex)
{
ExceptionManager.Publish(ex);
TraceCallReturnEvent.Raise(false);
throw;
}
}
示例7: ContinuativeDelete
public new void ContinuativeDelete(Continuative entity)
{
//check permission: Admin
PrincipalPermission permAdm = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
permAdm.Demand();
TraceCallEnterEvent.Raise();
try
{
base.ContinuativeDelete(entity);
BusinessAuditEvent.Success(
new EventParameter("ContinuativeID", entity.ID)
);
TraceCallReturnEvent.Raise();
return;
}
catch (Exception ex)
{
ExceptionManager.Publish(ex);
BusinessAuditEvent.Fail(
new EventParameter("Exception", ex.ToString()),
new EventParameter("ContinuativeID", entity.ID));
TraceCallReturnEvent.Raise(false);
throw;
}
}
示例8: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
// Check permission: all registered user
PrincipalPermission perm = new PrincipalPermission(Context.User.Identity.Name, "Registered");
perm.Demand();
if (!Page.IsPostBack)
{
ShowGrid(gridCompetition, 0, null, null);
}
}
示例9: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
SetDefaultControls("btnModify", "");
// Check permission: all registered user
PrincipalPermission perm = new PrincipalPermission(Context.User.Identity.Name, "Registered");
perm.Demand();
SetTitle(" - Felhasználói adatok");
if (!Page.IsPostBack)
{
RetreivData();
}
}
示例10: Main
static void Main(string[] args)
{
Console.WriteLine("\nWindows Identity");
WindowsIdentity identity = WindowsIdentity.GetCurrent();
Console.WriteLine("Authentication Type: " + identity.AuthenticationType);
Console.WriteLine("Name: " + identity.Name);
Console.WriteLine("Is System: " + identity.IsSystem);
Console.WriteLine("Is Authenticated: " + identity.IsAuthenticated);
Console.WriteLine("Owner Value: " + identity.Owner.Value);
Console.WriteLine("User Value: " + identity.User.Value);
Console.WriteLine("Token: " + identity.Token.ToString());
Console.WriteLine("Groups:");
IdentityReferenceCollection groups = identity.Groups;
foreach (IdentityReference ir in groups)
{
Console.WriteLine(" - Value: " + ir.Value);
}
Console.WriteLine("\nWindows Principal");
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal;
Console.WriteLine("Identity Name: " + principal.Identity.Name);
Console.WriteLine("\nUser Roles: ");
Console.WriteLine("Administrator: " + principal.IsInRole(WindowsBuiltInRole.Administrator));
Console.WriteLine("Power User: " + principal.IsInRole(WindowsBuiltInRole.PowerUser));
Console.WriteLine("User: " + principal.IsInRole(WindowsBuiltInRole.User));
try
{
PrincipalPermission pp = new PrincipalPermission(PermissionState.None);
Console.WriteLine("ToString: " + pp.ToString());
pp.Demand();
Console.WriteLine("Success!");
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
try
{
SuperDuperMethod();
}
catch (Exception e)
{
Console.WriteLine("Super Duper method threw a far out exception: " + e.ToString());
}
}
示例11: Main
static void Main(string[] args)
{
try
{
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
/*
string id1 = "Bob";
string role1 = "Manager";
PrincipalPermission principalPermission1 = new PrincipalPermission(id1, role1);
PrincipalPermission principalPermission2 = new PrincipalPermission("Louise", "Supervisor");
(principalPermission1.Union(principalPermission2)).Demand();
*/
WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal;
Console.WriteLine("Identity name: " + principal.Identity.Name);
Console.WriteLine("Authentication type: " + principal.Identity.AuthenticationType);
Console.WriteLine("IsInRole(\"administrators\"): " + principal.IsInRole("Administrators").ToString());
Console.WriteLine("Checking that the current user is \"EZETOP\\dobyrne\" and that they are in the " +
"\"administrators\" group \\ role:");
PrincipalPermission permission = new PrincipalPermission("EZETOP\\dobyrne", "administrators");
permission.Demand();
Console.WriteLine("Demand succeeded.");
Console.WriteLine("\nChecking that the current user is in the \"administrators\" role. I know we did" +
" it already but it's on the page:");
PrincipalPermission principalPerm = new PrincipalPermission(null, "Administrators");
principalPerm.Demand();
Console.WriteLine("Demand succeeded.");
Console.WriteLine("\nPlease be sure to note that if either the \"name\" or \"role\" passed to a " +
"PrincipalPermission constructor are null it means that any value is accepted.");
Console.WriteLine("Checking if unrestricted: ");
PrincipalPermission finalPerm = new PrincipalPermission(PermissionState.Unrestricted);
finalPerm.Demand();
Console.WriteLine("Demand succeeded, the current principal is unrestricted.");
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.ToString());
}
}
示例12: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (Context.User.Identity.IsAuthenticated)
{
PrincipalPermission permReg = new PrincipalPermission(Context.User.Identity.Name, "Registered");
permReg.Demand();
}
if (!Page.IsPostBack)
{
SetSearchLabel();
ShowForumGroupGrid(gridForumGroup, 0, null, null);
}
//SearchStrategyIFrame(lblSearch, lblIframe);
}
示例13: Main
public Main()
{
InitializeComponent();
Program.Project.Changed += new EventHandler<Library.ChangedEventArgs>(Project_Changed);
this.InitUI();
PrincipalPermission permission = new PrincipalPermission(null, "Administrators");
try
{
permission.Demand();
}
catch (SecurityException ex)
{
this.envoyerToolStripMenuItem.Visible = false;
}
}
开发者ID:hugonjerome,项目名称:CSharp-4-Developpez-des-applications-Windows-avec-Visual-Studio-2010,代码行数:16,代码来源:Main.cs
示例14: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
SetDefaultControls("btnCreate", "txtName");
PrincipalPermission permReg = new PrincipalPermission(Context.User.Identity.Name, "Registered");
permReg.Demand();
string orgId = Request["orgId"];
if (orgId == null)
throw new ApplicationException("Hiányzó kötelezõ paraméter: szervezet azonosító.");
Guid orgGuid = new Guid(orgId);
string writerRole = orgId + ".Writer";
PrincipalPermission permWriter = new PrincipalPermission(Context.User.Identity.Name, writerRole);
permWriter.Demand();
txtDescription.Attributes.Add("onkeyup", "DescriptionChanged()");
}
示例15: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
// Check permission: all registered user
PrincipalPermission perm = new PrincipalPermission(Context.User.Identity.Name, "Registered");
perm.Demand();
if (!Page.IsPostBack)
{
//a hírek dinamikus feltöltése
INewsCategoryService srvNewsCateg = ServiceFactory.GetNewsCategoryService();
NewsCategoryContainer categCont = srvNewsCateg.NewsCategorySelectAll();
foreach (NewsCategory item in categCont.All.SortBy("Rank", true))
{
CreateControl(item.ID, item.Name);
}
}
}