次の方法で共有


セキュリティ記述子のプロパティ型

nTSecurityDescriptor などのプロパティは、String(NT-Sec_Desc) 構文型を使用します。この型のプロパティが Properties プロパティで取得される場合、このデータ型は IADsSecurityDescriptor にキャストできる COM オブジェクトとして表されます。この型のプロパティが ResultPropertyValueCollection から取得される場合、このデータ型は Byte 値の配列として表されます。nTSecurityDescriptor プロパティ、String(NT-Sec_Desc) 構文型、および IADsSecurityDescriptor インターフェイスの詳細については、MSDN ライブラリ (https://go.microsoft.com/fwlink/?LinkID=27252) で、nTSecurityDescriptor、String(NT-Sec_Desc)、および IADsSecurityDescriptor に関するトピックを参照してください。

.NET Framework 2.0 以降、Active Directory ドメイン サービス オブジェクトのセキュリティ記述子は、ActiveDirectorySecurity クラスで表され、ObjectSecurity プロパティで取得または設定できます。

次の Visual Basic の例は、オブジェクトのセキュリティ記述子を読み取る方法を示しています。

Imports ActiveDS
Imports System.Collections

Dim ent As New DirectoryEntry("LDAP://CN=My User Name,OU=Marketing,DC=fabrikam,DC=com")
Dim sd As SecurityDescriptor = CType(ent.Properties("ntSecurityDescriptor").Value, SecurityDescriptor)
Dim acl As AccessControlList = CType(sd.DiscretionaryAcl, AccessControlList) 
Dim ace As AccessControlEntry
For Each ace In  CType(acl, IEnumerable)
    Console.WriteLine("Trustee: {0}", ace.Trustee)
    Console.WriteLine("AccessMask: {0}", ace.AccessMask)
    Console.WriteLine("Access Type: {0}", ace.AceType)
Next ace
using ActiveDs;
using System.Collections;

DirectoryEntry ent = new DirectoryEntry("LDAP://CN=My User Name,OU=Marketing,DC=fabrikam,DC=com");
SecurityDescriptor sd = (SecurityDescriptor) ent.Properties["ntSecurityDescriptor"].Value; 
AccessControlList acl= (AccessControlList) sd.DiscretionaryAcl;

foreach(AccessControlEntry ace in (IEnumerable) acl)
{
    Console.WriteLine("Trustee: {0}", ace.Trustee);
    Console.WriteLine("AccessMask: {0}", ace.AccessMask);
    Console.WriteLine("Access Type: {0}", ace.AceType);
}

次の Visual Basic の例は、オブジェクトにセキュリティ記述子を書き込む方法を示しています。

Import ActiveDS

Dim usr As New DirectoryEntry("LDAP://CN=My User Name,OU=Marketing,DC=fabrikam,DC=com")
Dim newAce = New AccessControlEntryClass()
Dim usrSD As SecurityDescriptor = CType(usr.Properties("ntSecurityDescriptor").Value, SecurityDescriptor)
Dim usrAcl As AccessControlList = CType(usrSD.DiscretionaryAcl, AccessControlList)
newAce.Trustee = "AliceW"
newAce.AccessMask = - 1
newAce.AceType = 0
usrAcl.AddAce(newAce)
usrSD.DiscretionaryAcl = usrAcl
usr.Properties("ntSecurityDescriptor").Value = usrSD
usr.CommitChanges()
using ActiveDS;

DirectoryEntry usr = new DirectoryEntry("LDAP://CN=My User Name,OU=Marketing,DC=fabrikam,DC=com");
AccessControlEntry newAce = new AccessControlEntryClass();
SecurityDescriptor usrSD = (SecurityDescriptor)usr.Properties["ntSecurityDescriptor"].Value; AccessControlList usrAcl= (AccessControlList) usrSD.DiscretionaryAcl;
newAce.Trustee = "AliceW";
newAce.AccessMask = -1;
newAce.AceType = 0;
usrAcl.AddAce(newAce);
usrSD.DiscretionaryAcl = usrAcl;
usr.Properties["ntSecurityDescriptor"].Value = usrSD;
usr.CommitChanges();

関連項目

リファレンス

System.DirectoryServices
ActiveDirectorySecurity
DirectoryEntry
ResultPropertyValueCollection
Byte

概念

プロパティの型

Send comments about this topic to Microsoft.

Copyright © 2007 by Microsoft Corporation. All rights reserved.