개체에 대한 보안 설명자가 있습니다. 해당 보안 설명자를 사용하여 해당 개체에 대한 사용 권한을 가진 사용자 및 그룹을 가져 오려고합니다. 해당 보안 설명자를 사용하여 어떤 사용자가 어떤 사용 권한을 갖고 있는지 알고있는 방법? ObjectSecurity 또는 CommonObjectSecurity 추상 클래스를 사용할 수 있습니까? 그렇다면 액세스 규칙을 정의하는 방법은 무엇입니까? 이것에 대한 샘플이 있습니까?.Net에서 보안을 구현하는 방법은 무엇입니까?
1
A
답변
2
권한이있는 사용자 및 그룹에 액세스하려면 .Net에서 쉽게 메커니즘을 사용할 수 있습니다. 추상 클래스 인 CommonObjectSecurity 클래스를 구현하고 AccessRuleFactory 및 AuditRuleFactory 메서드를 재정의하고 AccessRuleType 및 AuditRuleType 속성을 재정의합니다. 다음 예제에서 SampleSecurity 클래스는 CommonObjectSecurity에서 파생됩니다. 또한 AccessRule에서 SampleAccessRule 클래스를 정의합니다. 선택적으로 AddAccessRule 및 RemoveAccessRule을 구현하여 보안을 수정할 수 있습니다.
public class SampleSecurity : CommonObjectSecurity
{
public SampleSecurity(bool isContainer)
: base(isContainer)
{
}
public override AccessRule AccessRuleFactory(IdentityReference identityReference,
int accessMask, bool isInherited, InheritanceFlags inheritanceFlags,
PropagationFlags propagationFlags, AccessControlType type)
{
return new SampleAccessRule(identityReference, accessMask, type);
}
public void AddAccessRule(IdentityReference identityReference,
int accessMask, AccessControlType type)
{
base.AddAccessRule(new ProxyAccessRule(identityReference, accessMask, type));
}
public void RemoveAccessRule(ProxyAccessRule rule)
{
base.RemoveAccessRule(rule);
}
public override Type AccessRuleType
{
get { return typeof(ProxyAccessRule); }
}
public override AuditRule AuditRuleFactory(System.Security.Principal.IdentityReference identityReference, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags)
{
throw new NotImplementedException();
}
public override Type AuditRuleType
{
get { throw new NotImplementedException(); }
}
public override Type AccessRightType
{
get { return typeof(SampleRightsEnum); }
}
}
public class SampleAccessRule : AccessRule
{
public ProxyAccessRule(IdentityReference identity, int accessMask, AccessControlType accessType)
: base(identity, accessMask, false, InheritanceFlags.None, PropagationFlags.None, accessType)
{
}
public int AccessRights { get { return AccessMask; } }
}
public enum SampleRightsEnum
{
sampleRead = 0x001,
sampleWrite = 0x002,
sampleExecute = 0x004
}
이가 정의되면, 우리는 SampleSecurity의 객체를 생성하고 그것을 아래로 우리가 서로 다른 사용자에 대한 권한을 읽을 수있는 보안 설명을 할당 할 수 있습니다.
SampleSecurity security = new SampleSecurity(false);
security.SetSecurityDescriptorBinaryForm((byte[])securityDescriptor, AccessControlSections.All);
AuthorizationRuleCollection coll = dataSecurity.GetAccessRules(true, false, typeof(NTAccount));
foreach (AuthorizationRule rule in coll)
{
SampleAccessRule accRule = rule as SampleAccessRule;
SampleRightsEnum rights = (SampleRightsEnum)accRule.AccessRights;
Console.Writeline("User or Group {0} having the permissions {1} with access type {2}", rule.IdentityReference.Value, rights.ToString(), accRule.AccessControlType.ToString());
}
관련 문제
- 1. .net에서 멀티 스레딩을 구현하는 다른 방법은 무엇입니까
- 2. .Net에서 이것을 구현하는 가장 좋은 방법은 무엇입니까?
- 3. .NET에서 야간 프로세스를 구현하는 방법은 무엇입니까?
- 4. asp.net에서 역할 기반이 아닌 사용자 기본 보안을 구현하는 방법은 무엇입니까?
- 5. http를 통해 보안을 구현하는 가장 좋은 방법은 무엇입니까
- 6. .NET에서 PodPress를 구현하는 방법
- 7. .NET에서 DSL을 구현하는 도구
- 8. .net에서 추적을 구현하는 방법
- 9. 오늘날 .NET에서 RESTful 아키텍처를 구현하는 가장 좋은 방법은 무엇입니까?
- 10. .NET에서 Windows EventLog에 상관 ID를 구현하는 방법은 무엇입니까?
- 11. .NET에서 값 유형을 구현하는 방법
- 12. 내 프로젝트에서 Grails의 Shiro 보안을 구현하는 방법
- 13. 웹 서비스에서 메시지 수준 보안을 구현하는 방법
- 14. .NET에서 부드러운 스크롤을 구현하는 방법
- 15. C# .NET에서 "FIFO"를 사용하는 방법은 무엇입니까?
- 16. SOAP을 구현하는 방법은 무엇입니까?
- 17. 대기중인지도를 구현하는 방법은 무엇입니까?
- 18. IDEA를 구현하는 방법은 무엇입니까?
- 19. 리스너를 구현하는 방법은 무엇입니까?
- 20. initWithObjects를 구현하는 방법은 무엇입니까?
- 21. 스크롤을 구현하는 방법은 무엇입니까?
- 22. 배지를 구현하는 방법은 무엇입니까?
- 23. 동적 데이터 및 Active Directory를 사용하여 역할 기반 보안을 구현하는 방법은 무엇입니까?
- 24. 웹 응용 프로그램에서 사용자 및 그룹 보안을 구현하는 방법은 무엇입니까? PHP가 중요하다면
- 25. .NET에서 Winforms를 자동화하는 방법은 무엇입니까?
- 26. net에서 xml을 파싱하는 방법은 무엇입니까?
- 27. .net에서 네트워킹을 구성하는 방법은 무엇입니까?
- 28. .NET에서 IPC 버스를 구현하는 가장 좋은 메커니즘은 무엇입니까?
- 29. 런타임 라이센스를 구현하는 방법은 무엇입니까?
- 30. 조건부 구현을 구현하는 방법은 무엇입니까?
나는'ProxyAccessRule'이 무엇인지 알지 못합니다. 나에게 계몽 해 줄 수있어? .Net에서 사용할 수있는 네임 스페이스로 표시되지 않습니다. 관습? 그렇다면 클래스가 수행하는 작업의 예를 제공하는 것이 도움이 될 수 있습니다. 이 대답은 더 많은 upvotes를 얻을 수 있습니다. – IAbstract
nvm, 알아 냈습니다. 나는 네가 실수 한 것 같아. 당신은 클래스를'SampleAccessRule'으로 정의했지만,'ProxyAccessRule'으로 정의 된 생성자를 제공했습니다. – IAbstract
이제'securityDescriptor' 변수가 무엇인지 이해하려고합니다. 어떤 힌트? – IAbstract