????? ??????? Visual Basic ADsSecurity.dll ?????? ACEs ???? ???? ?? ACL

?????? ????????? ?????? ?????????
???? ???????: 269159 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ?????? ????? ??????? ADsSecurity.dll ?????? ??? ???? ???? (SD) ????? ?? ???? "Active Directory" ?? ????? ???????. ???? ??? ??????? ????? ?????? ????? ????? ?????? ???? ?????? ????? ??? ??????? ????? ?????? ??????? ??????? (ACL) ?? ??? SD ?? ????? ????? ?????? ??????? (ACE) ?? ?????? ??????. ???? ??????? ???????? ????? ?? ???? ??? Microsoft Visual Basic ?????? ????? ????? ACL ???? ???? ?? ????? ACL SD.

??????? ????

????? ????? IADsAccessControlList::AddAce ACE ?? ???? ????? ?????? ??????? (ACL). ?? ??? ???????? ??? ????? ????? ACE ?? ?????? ???? ??? ????? ??????. ???? ??????? ?????? ??????? ?????? ???? ???? Active Directory (ADSI) ?? ???? ??????? Windows Server 2003 ??? Windows XP ????? DACL ???? ???? ??? ??????? ??? ???? ??? ??????. ????? ????? ????? ??? ?? Microsoft Windows 2000. ????? ???????? ACEs ?? ACL ??? ???:
ACE ??? ?????? ???? ????? ??? ?????? ????
ACE ??? ?????? ???? ????? ??? ???? ?????? ??? ?????? ??????? ?? ???????
ACE ?????? ??????? ???? ????? ??? ?????? ????
ACE ?????? ??????? ???? ????? ??? ???? ?????? ??? ?????? ??????? ?? ???????
?? ???????? ??????? ?? ??? ??????? ?? ????? ????? IADsAccessControlList ????? ???????? ACL ???? ????. ??? ?? ??? ??? ACE ??? ??? ????????? ?????:
??? ?????? ??? ??????
??? ?????? ??? ??????? ?? ?????
?????? ??????? ??? ??????
?????? ??????? ??? ??????? ?? ?????
???? ????? ACE
????? ACEs ???????? ??? ?? ??? ?? ?????. ???? ACEs ???????? ?????? ??? ???? ??????? ? ????? ???? ?????. ???? ????? ??????? ??? ?? ??? ????? ACE ? Windows 2000 ?? Windows NT ??? ?????? ????? ??? ACE ??? ???????? ???????.

???? ??????? ????? ???. ????? ??? ACL ?????? ???? ?? ???????? ?????? ??? ????? ???????? ???????? ?? ???? ???? ??????. ??? ??????? ??????? ???? ?????? ?? ??? ACE ?? ???? ????? ACE ??? ?????? ??????. ??? ??? ??? ACE ??? ?????? ????? ?? ?????? ???????.

???????? ????? ACEs ?? ACL

  1. ?????? ??? ACL ??????? (DACL) ?? ???? ??????.
  2. ???? ?? IADsAccessControlEntry::AceFlags ?????? ?? ??? ??? ?? ACE ?????? (?????? ?? ADS_ACEFLAG_INHERITED_ACE ??).
  3. ???? ?? IADsAccessControlEntry::AceType ??????? ?? ?? ??? ?? ACE ??? ?????? ?? ??? ??? ?? ?????? ??? (?????? ???? ?? ????? ??????). ???? ??????? ??????? ??? ??? ACE "?" ???? ????:
    ???? ADS_ACETYPE_ACCESS_ALLOWED - ??????? ?? ?????? ??? ?????? ??????
    ???? ??? ADS_ACETYPE_ACCESS_ALLOWED_OBJECT - ????? ?????? ??? ????? ?? ?????? ???????
    ADS_ACETYPE_ACCESS_DENIED - ???? ?????? ??? ?????? ??????
    ADS_ACETYPE_ACCESS_DENIED_OBJECT - ???? ?????? ??? ????? ?? ?????? ???????.
  4. ?? ACE ?? DACL ??????? ???????? ???????? ??? ???? IADsAccessControlListEntry::AceType.
  5. ????? ????? ACL ?? ACLs ?????? ???????? ??????:
    ????? ADS_ACETYPE_ACCESS_DENIED ACE
    ????? ADS_ACETYPE_ACCESS_DENIED_OBJECT ACE
    ????? ADS_ACETYPE_ACCESS_ALLOWED ACE
    ????? ADS_ACETYPE_ACCESS_ALLOWED_OBJECT ACE
    ????? ???? ????? ADS_ACEFLAG_INHERITED_ACE ?? IADsAccessControlListEntry::AceFlags
  6. ????? ACL ?????? ??? ??? ACL ?????? ????? ????????.
  7. ??????? ACL ??? ???? ??????.

??????? ???????? ????????? ???????? ?? Visual Basic ???? ??? ?????? ?? ??? ???????

  1. ????? ADsSecurity.dll.

    ADsSecurity.dll ????? ?? Active Directory ???? ???? ?????? (ADSI) 2.5 Resource Kit. ?????? ?????? ADSI 2.5 ??????? ?? ?????? ???? Microsoft ?????? ??? ?????:
    http://www.microsoft.com/technet/archive/winntas/downloads/adsi25.mspx?mfr=true
    ??????? Regsvr32 ?????? ADsSecurity.dll. ??? ?? ????? DLL ??? ???? ????, ???? ??? ?????? ??? ????? ADSI. ??? ??? ???? ?????? ????????? ???????? ??? ???? ??????? ???? ????? ??????? Microsoft Windows NT ?? ??? ???? ??????? ????? ??? ???? ??????? Microsoft Windows 98 ????? "???? ??????" ??????? ???? Active Directory. ????? ?? ????????? ??? ????? ?????? ??? ??? ??????? ??????? ???? ??? "???????".
  2. ??? ????? Visual Basic. ?? ?? ?????? ????? EXE ??????.
  3. ??? ????? ???????. ???? ?? ????? ????:
    • ????? ??? DS ?????
    • ????? ??? ADsSecurity 2.5
  4. ??? ?? ??? ?? ???????.
  5. ???? ????? ??????? ??? ?? ?????. ?? ?? ???? ???????? ???????? ??????? ?? ????? ????? Command1_Click.

????? ???????? ???????? Visual Basic ???? ????? ????? ???????? ?????

Dim sec As New ADsSecurity
Dim sd As IADsSecurityDescriptor
Dim dacl As IADsAccessControlList
Dim ace As IADsAccessControlEntry
Dim newAce As New AccessControlEntry
'
' Declare temporary ACLs for sorting the original
' ACL
'
Dim newdacl As New AccessControlList
Dim ImpDenyDacl As New AccessControlList
Dim ImpDenyObjectDacl As New AccessControlList
Dim InheritedDacl As New AccessControlList
Dim ImpAllowDacl As New AccessControlList
Dim impAllowObjectDacl As New AccessControlList

Private Sub Command1_Click()
'
' Be sure to register ADsSecurity.Dll using RegSvr32 and
' adding the ADsSecurity2.5 Type Library to you references for
' the project.
'
' Using the ADsSecurity object, retrieve a SD for an object.  Just
' Replace the LDAP:// path with the path of an object that contains a
' SD.  For additional details on valid path strings, review
' the information stored in the Platform SDK ADSI samples starting with
' "<Platform SDK Root>\Samples\NetDs\ADSI\rtk.htm"
'
Set sec = CreateObject("ADsSecurity")<BR/>
' TODO :  replace the servername and DN of the object you want to modify.
Set sd = sec.GetSecurityDescriptor("LDAP://MyDCname/cn=MyUser,cn=Users,dc=MyDom,dc=com")

'Displaying the ACE in the DACL --- it's the same way you display ACEs for File, File Share, Registry, Exchange, and Active Directory's ACL.

Set dacl = sd.DiscretionaryAcl
Debug.Print Date & Time & "Initial Values of DACL"
For Each ace In dacl
   Debug.Print ace.Trustee
   Debug.Print Hex(ace.AccessMask)
   Debug.Print Hex(ace.AceType)
   Debug.Print Hex(ace.AceFlags)
   Debug.Print Hex(ace.Flags)
Next

Debug.Print dacl.AceCount

'
' Initialize all of the new ACLs
'
' If you are doing this in VBSscript you will need to use
' The following methods of creating the ACL bins instead of
' using the Dim As New statements above. 
'
'Set newAce = CreateObject("AccessControlEntry")
'Set newdacl = CreateObject("AccessControlList")
'Set InheritedDacl = CreateObject("AccessControlList")
'Set ImpAllowDacl = CreateObject("AccessControlList")
'Set InhAllowDacl = CreateObject("AccessControlList")
'Set ImpDenyObjectDacl = CreateObject("AccessControlList")
'Set ImpAllowObjectDacl = CreateObject("AccessControlList")
'
'
' Create a new ace, this one
' sets an extended right on the user object that allows the
' trustee to read and write the userAccountControl property of an
' user object.
'
' TODO : Replace the trustee with an appropriate trustee on the domain
' in question.
'
newAce.Trustee = "MyDomain\Myuser"
newAce.Flags = ADS_FLAG_OBJECT_TYPE_PRESENT
newAce.ObjectType = "{BF967A68-0DE6-11D0-A285-00AA003049E2}"
newAce.AccessMask = ADS_RIGHT_DS_READ_PROP Or ADS_RIGHT_DS_WRITE_PROP
newAce.AceType = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT
newAce.AceFlags = ADS_ACEFLAG_INHERIT_ACE
'
' Place the new ace in the DACL
'
dacl.AddAce newAce
'
' Sift the DACL into 5 bins:
' Inherited Aces
' Implicit Deny Aces
' Implicit Deny Object Aces
' Implicit Allow Aces
' Implicit Allow object aces
'
For Each ace In dacl
  '
  ' Sort the original ACEs into their appropriate
  ' ACLs
  '
  Debug.Print ace.Trustee
  If ((ace.AceFlags And ADS_ACEFLAG_INHERITED_ACE) = ADS_ACEFLAG_INHERITED_ACE) Then
     '
     ' Do not really care about the order of inherited aces. Since we are
     ' adding them to the top of a new list, when they are added back
     ' to the Dacl for the object, they will be in the same order as
     ' they were originally. Just a positive side effect of adding items
     ' of a LIFO (Last In First Out) type list.
     '
     InheritedDacl.AddAce ace
  Else
     '
     ' We have an Implicit ACE, let's put it the proper pool
     '
     Select Case ace.AceType
     Case ADS_ACETYPE_ACCESS_ALLOWED
        '
        ' We have an implicit allow ace
        '
        ImpAllowDacl.AddAce ace
     Case ADS_ACETYPE_ACCESS_DENIED
        '
        ' We have an implicit Deny ACE
        '
        ImpDenyDacl.AddAce ace
     Case ADS_ACETYPE_ACCESS_ALLOWED_OBJECT
        '
        ' We have an object allowed ace
        ' Does it apply to a property? or an Object?
        '
        impAllowObjectDacl.AddAce ace
     Case ADS_ACETYPE_ACCESS_DENIED_OBJECT
        '
        ' We have an object Deny ace
        '
        ImpDenyObjectDacl.AddAce ace
     Case Else
        '
        ' Missed a bin?
        '
        Debug.Print "Bad ace...." & Hex(ace.AceType)
     End Select
  End If
Next
'
' Combine the ACEs in the proper order
' Implicit Deny
' Implicit Deny Object
' Implicit Allow
' Implicit Allow Object
' Inherited aces
'
' Implicit Deny
'
For Each ace In ImpDenyDacl
  newdacl.AddAce ace
Next
'
' Implicit Deny Object
'
For Each ace In ImpDenyObjectDacl
  newdacl.AddAce ace
Next
'
' Implicit Allow
'
For Each ace In ImpAllowDacl
  newdacl.AddAce ace
Next
'
' Implicit Allow Object
'
For Each ace In impAllowObjectDacl
  newdacl.AddAce ace
Next
'
' Inherited Aces
'
For Each ace In InheritedDacl
  newdacl.AddAce ace
Next

sd.DiscretionaryAcl = newdacl
Debug.Print Date
For Each ace In newdacl
   Debug.Print ace.Trustee
   Debug.Print "Ace Mask: " & Hex(ace.AccessMask)
   Debug.Print "Ace Type: " & Hex(ace.AceType)
   Debug.Print "Ace Flags: " & Hex(ace.AceFlags)
   Debug.Print "Object Type value: " & Hex(ace.Flags)
   Debug.Print "Object Guid : " & ace.ObjectType
Next
'
' Set the appropriate revision level
' for the DACL
'
newdacl.AclRevision = dacl.AclRevision
'
' Replace the Security Descriptor
'
sec.SetSecurityDescriptor sd
' If this generates the error -214023559 or 80070539 check your TODO
' strings.  This error is most likely a problem with DNS name resolution.
				

?????

?????? ??? ??????? ??????? ???? ??? ????? ???????? ??????? ?????? ?? "????? ??????? ?? Microsoft:
269175????? ??????? Visual C++ ?????? ACEs ???? ???? ?? ACL
279682????? ??????? ADsSecurity.dll ?????? ????? ???? ???? ??? ???? NTFS
?????? ??? ??????? ?????? ??? ????? ????? "???? ?????? ???? Active Directory" ???? ??? ??? ??????? ?????? ?????? ?? "????? ??????? ?? Microsoft:
288358????? ????? "???? ???? Active Directory ??? ??????"

???????

???? ???????: 269159 - ????? ??? ??????: 25/?? ?????/1427 - ??????: 7.1
????? ???
  • Microsoft Active Directory Service Interfaces 2.5
  • Microsoft Active Directory Service Interfaces 2.5
  • Microsoft Windows Scripting Host 2.5
????? ??????: 
kbmt kbdswadsi2003swept kbhowto KB269159 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????269159
????? ??????? ?? ????? ???? ?? ????? ???????
?? ????? ????? ?????? ???? ???? ???? ??? ??????? ??? ?? ? ?? ??? ??????? Microsoft ??? ????? ??? ??????? ????? ?????? ?????

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com