DACL DACL(Discretionary Access Control List)
This is a list that controls who can do what with your server objects. An administrator can use DCOMCNFG to configure the DACL.
DACL 类型编辑本段两种类型的ACL:自由决定的(DACL)和系统的
(SACL)。DACL管制对象访问,SACL管制审核。
1
public
static
Boolean SetDirPermission(String strSitePath, String strUserName,
ref
string
ErrorMsg)
2![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
3![](/Images/OutliningIndicators/InBlock.gif)
4
Boolean bOk;
5![](/Images/OutliningIndicators/InBlock.gif)
6
try
7![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
8![](/Images/OutliningIndicators/InBlock.gif)
9
// Directory.CreateDirectory(strSitePath);
10![](/Images/OutliningIndicators/InBlock.gif)
11
SecurityDescriptor secDesc = SecurityDescriptor.GetFileSecurity(strSitePath,
12![](/Images/OutliningIndicators/InBlock.gif)
13
SECURITY_INFORMATION.DACL_SECURITY_INFORMATION);
14![](/Images/OutliningIndicators/InBlock.gif)
15
Dacl dacl = secDesc.Dacl;
16![](/Images/OutliningIndicators/InBlock.gif)
17
Sid sidUser = new Sid (strUserName);
18![](/Images/OutliningIndicators/InBlock.gif)
19
20![](/Images/OutliningIndicators/InBlock.gif)
21
// allow: folder, subfolder and files
22![](/Images/OutliningIndicators/InBlock.gif)
23
// modify
24![](/Images/OutliningIndicators/InBlock.gif)
25
dacl.AddAce (new AceAccessAllowed (sidUser, AccessType.GENERIC_ALL | AccessType.GENERIC_WRITE |
26![](/Images/OutliningIndicators/InBlock.gif)
27
AccessType.GENERIC_READ | AccessType.DELETE | AccessType.GENERIC_EXECUTE , AceFlags.OBJECT_INHERIT_ACE |
28![](/Images/OutliningIndicators/InBlock.gif)
29
AceFlags.CONTAINER_INHERIT_ACE));
30
31![](/Images/OutliningIndicators/InBlock.gif)
32
// deny: this folder
33![](/Images/OutliningIndicators/InBlock.gif)
34
// write attribs
35![](/Images/OutliningIndicators/InBlock.gif)
36
// write extended attribs
37![](/Images/OutliningIndicators/InBlock.gif)
38
// delete
39![](/Images/OutliningIndicators/InBlock.gif)
40
// change permissions
41![](/Images/OutliningIndicators/InBlock.gif)
42
// take ownership
43
//
44
// DirectoryAccessType DAType = DirectoryAccessType.DELETE | DirectoryAccessType.WRITE_OWNER |
45![](/Images/OutliningIndicators/InBlock.gif)
46
DirectoryAccessType.WRITE_DAC;
47
//
48
// AccessType AType = (AccessType)DAType;
49
//
50
// dacl.AddAce (new AceAccessDenied (sidUser, AType));
51![](/Images/OutliningIndicators/InBlock.gif)
52
53![](/Images/OutliningIndicators/InBlock.gif)
54
secDesc.SetDacl(dacl);
55![](/Images/OutliningIndicators/InBlock.gif)
56
secDesc.SetFileSecurity(strSitePath, SECURITY_INFORMATION.DACL_SECURITY_INFORMATION);
57![](/Images/OutliningIndicators/InBlock.gif)
58
bOk = true;
59![](/Images/OutliningIndicators/InBlock.gif)
60
}
61
catch (Exception ee)
62![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
63![](/Images/OutliningIndicators/InBlock.gif)
64
ErrorMsg=ee.Message;
65
bOk=false;
66![](/Images/OutliningIndicators/InBlock.gif)
67
}
68![](/Images/OutliningIndicators/InBlock.gif)
69
return bOk;
70![](/Images/OutliningIndicators/InBlock.gif)
71
}
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
3
![](/Images/OutliningIndicators/InBlock.gif)
4
![](/Images/OutliningIndicators/InBlock.gif)
5
![](/Images/OutliningIndicators/InBlock.gif)
6
![](/Images/OutliningIndicators/InBlock.gif)
7
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
8
![](/Images/OutliningIndicators/InBlock.gif)
9
![](/Images/OutliningIndicators/InBlock.gif)
10
![](/Images/OutliningIndicators/InBlock.gif)
11
![](/Images/OutliningIndicators/InBlock.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/InBlock.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/InBlock.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/InBlock.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/InBlock.gif)
36
![](/Images/OutliningIndicators/InBlock.gif)
37
![](/Images/OutliningIndicators/InBlock.gif)
38
![](/Images/OutliningIndicators/InBlock.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/InBlock.gif)
41
![](/Images/OutliningIndicators/InBlock.gif)
42
![](/Images/OutliningIndicators/InBlock.gif)
43
![](/Images/OutliningIndicators/InBlock.gif)
44
![](/Images/OutliningIndicators/InBlock.gif)
45
![](/Images/OutliningIndicators/InBlock.gif)
46
![](/Images/OutliningIndicators/InBlock.gif)
47
![](/Images/OutliningIndicators/InBlock.gif)
48
![](/Images/OutliningIndicators/InBlock.gif)
49
![](/Images/OutliningIndicators/InBlock.gif)
50
![](/Images/OutliningIndicators/InBlock.gif)
51
![](/Images/OutliningIndicators/InBlock.gif)
52
![](/Images/OutliningIndicators/InBlock.gif)
53
![](/Images/OutliningIndicators/InBlock.gif)
54
![](/Images/OutliningIndicators/InBlock.gif)
55
![](/Images/OutliningIndicators/InBlock.gif)
56
![](/Images/OutliningIndicators/InBlock.gif)
57
![](/Images/OutliningIndicators/InBlock.gif)
58
![](/Images/OutliningIndicators/InBlock.gif)
59
![](/Images/OutliningIndicators/InBlock.gif)
60
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
61
![](/Images/OutliningIndicators/InBlock.gif)
62
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
63
![](/Images/OutliningIndicators/InBlock.gif)
64
![](/Images/OutliningIndicators/InBlock.gif)
65
![](/Images/OutliningIndicators/InBlock.gif)
66
![](/Images/OutliningIndicators/InBlock.gif)
67
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
68
![](/Images/OutliningIndicators/InBlock.gif)
69
![](/Images/OutliningIndicators/InBlock.gif)
70
![](/Images/OutliningIndicators/InBlock.gif)
71
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
SECURITY_INFORMATION
The SECURITY_INFORMATION type identifies the object-related security information being set or queried. This security information includes:
- The owner of an object
- The primary group of an object
- The discretionary access control list (DACL) of an object
- The system access control list (SACL) of an object
typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
Remarks
Windows 2000: New SECURITY_INFORMATION members only work with the SetNamedSecurityInfo function. These new members are not returned in the structure returned by other security functions such as GetNamedSecurityInfo or ConvertStringSecurityDescriptorToSecurityDescriptor.
Each item of security information is designated by a bit flag. The following values specify the bits.
Value | Meaning |
---|---|
DACL_SECURITY_INFORMATION | Indicates the DACL of the object is being referenced. |
GROUP_SECURITY_INFORMATION | Indicates the primary group identifier of the object is being referenced. |
OWNER_SECURITY_INFORMATION | Indicates the owner identifier of the object is being referenced. |
PROTECTED_DACL_SECURITY_INFORMATION | Windows 2000/XP: Indicates the DACL cannot inherit ACEs. |
PROTECTED_SACL_SECURITY_INFORMATION | Windows 2000/XP: Indicates the SACL cannot inherit ACEs. |
SACL_SECURITY_INFORMATION | Indicates the SACL of the object is being referenced. |
UNPROTECTED_DACL_SECURITY_INFORMATION | Windows 2000/XP: Indicates the DACL inherits ACEs from the parent object. |
UNPROTECTED_SACL_SECURITY_INFORMATION | Windows 2000/XP: Indicates the SACL inherits ACEs from the parent object. |