本文整理汇总了C#中System.Security.Permissions.PrincipalPermission类的典型用法代码示例。如果您正苦于以下问题:C# PrincipalPermission类的具体用法?C# PrincipalPermission怎么用?C# PrincipalPermission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PrincipalPermission类属于System.Security.Permissions命名空间,在下文中一共展示了PrincipalPermission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
}
示例2: NewsAttachmentDelete
public new void NewsAttachmentDelete(NewsAttachment entity)
{
// check permission: admin
PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered");
PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
permReg.Union(permAdmin).Demand();
TraceCallEnterEvent.Raise();
try
{
FileDataContext fileDataContext = new FileDataContext();
string ext = Path.GetExtension(entity.Path).ToLower();
string fileName = entity.ID.ToString() + ext;
fileDataContext.NewsAttachmentDelete(entity.NewsRef, fileName);
base.NewsAttachmentDelete(entity);
BusinessAuditEvent.Success();
TraceCallReturnEvent.Raise();
return;
}
catch (Exception ex)
{
ExceptionManager.Publish(ex);
BusinessAuditEvent.Fail(
new EventParameter("Exception", ex.ToString())
);
TraceCallReturnEvent.Raise(false);
throw;
}
}
示例3: 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();
}
}
}
示例4: testRoleBtn_Click
//[PrincipalPermission(SecurityAction.Demand, Name="aa")]
protected void testRoleBtn_Click(object sender, EventArgs e)
{
var aPermission = new PrincipalPermission("a", null);
var bPermission = new PrincipalPermission("b", null);
aPermission.Union(bPermission).Demand();
//permission.Demand();
}
示例5: JobAnswerDelete
public new void JobAnswerDelete(JobAnswer entity)
{
PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered");
PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
permReg.Union(permAdmin).Demand();
base.JobAnswerDelete(entity);
}
示例6: Authorize
public void Authorize()
{
string[] groups = null;
Type serviceType = this.GetType();
var configItem = WcfConfigManager.GetServiceConfig(serviceType);
if (null != configItem)
{
groups = configItem.Item.AuthorizedGroups.Split(',');
}
if (null != groups)
{
PrincipalPermission[] pps = new PrincipalPermission[groups.Length];
for (int i = 0; i < groups.Length; i++)
{
pps[i] = new PrincipalPermission(null, groups[i]);
}
PrincipalPermission pp = pps[0];
if (groups.Length > 0)
{
for (int i = 1; i < groups.Length; i++)
{
pp = (PrincipalPermission)pp.Union(pps[i]);
}
}
pp.Demand();
}
else
throw new SecurityException("Group is null");
}
示例7: OfficerMethod
public static void OfficerMethod()
{
string name = "��";
string role = "ʿ��";
PrincipalPermission principalPermission = new PrincipalPermission(name, role);
principalPermission.Demand();
}
示例8: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.Redirect("Default.aspx");
SetTitle(" - Állásajánlatra jelentkezés rögzítése");
SetDefaultControls("btnCreate", "txtMotivation");
// Check permission: anybody can use this page
PrincipalPermission permReg = new PrincipalPermission(Context.User.Identity.Name, "Registered");
permReg.Demand();
string jobId = Request["jobId"];
m_sender = Request["sender"];
if (jobId == null)
throw new ApplicationException("Hiányzó kötelező paraméter: hirdetés azonosító.");
m_srvJob = ServiceFactory.GetJobOfferService();
m_JobId = new Guid(jobId);
m_Job = m_srvJob.JobOfferSelect(m_JobId);
if (!Page.IsPostBack)
{
RetreiveData();
#region Attachement grid feltöltése
ShowAttachementGrid();
#endregion
}
}
示例9: 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();
}
示例10: Authorize
public void Authorize()
{
var serviceType = this.GetType();
var configItem = Config.Get(serviceType);
IList<string> groups = null;
if (configItem != null)
{
groups = configItem.AuthorizedGroups;
}
if (groups == null)
{
throw new SecurityException("Group is null");
}
var pps = new PrincipalPermission[groups.Count];
for (var i = 0; i < groups.Count; i++)
{
pps[i] = new PrincipalPermission(null, groups[i]);
}
var pp = pps[0];
if (groups.Count> 0)
{
for (var i = 1; i < groups.Count; i++)
{
pp = (PrincipalPermission)pp.Union(pps[i]);
}
}
pp.Demand();
}
示例11: 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;
}
}
示例12: 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;
}
}
示例13: PermissionStateUnrestricted
public void PermissionStateUnrestricted ()
{
PrincipalPermission p = new PrincipalPermission (PermissionState.Unrestricted);
Assert.IsNotNull (p, "PrincipalPermission(PermissionState.Unrestricted)");
Assert.IsTrue (p.IsUnrestricted (), "IsUnrestricted");
PrincipalPermission copy = (PrincipalPermission) p.Copy ();
Assert.AreEqual (p.IsUnrestricted (), copy.IsUnrestricted (), "Copy.IsUnrestricted");
// Note: Unrestricted isn't shown in XML
}
示例14: PermissionStateUnrestricted
public void PermissionStateUnrestricted ()
{
PrincipalPermission p = new PrincipalPermission (PermissionState.Unrestricted);
AssertNotNull ("PrincipalPermission(PermissionState.Unrestricted)", p);
Assert ("IsUnrestricted", p.IsUnrestricted ());
PrincipalPermission copy = (PrincipalPermission) p.Copy ();
AssertEquals ("Copy.IsUnrestricted", p.IsUnrestricted (), copy.IsUnrestricted ());
// Note: Unrestricted isn't shown in XML
}
示例15: CreatePermission
// Method
public override IPermission CreatePermission ()
{
PrincipalPermission perm = null;
if (this.Unrestricted)
perm = new PrincipalPermission (PermissionState.Unrestricted);
else
perm = new PrincipalPermission (name, role, authenticated);
return perm;
}