O
Oroppas
Guest
Hey guys,
This is the story. I work for a company with over 7,000 computers that are locked down for security reasons so users have VERY limited rights on their computer. This means that some of their programs they need do NOT work since they do not have access to modify data that the program needs to be able to modify.
One of these areas is the system registry. We are working on a tool that will help us automate setting security permissions on said registry key's of the computers at our location.
We have found out how to do many of the functions we require but there are two areas we are 'stuck' on.
1) We need to find a way, if at all possible, to browse our Active Directory schema and select Containers and OU's to apply the automated security fixes on. I know it is possible since they have these api's available from Microsoft but we cannot get it to work correctly with Visual Basic. (I do not choose the programming language, I just do what I am told)
2) This is the biggest problem. We cannot figure out how to use Active Directory Service Interfaces (ADSI) to properly apply security settings on the registry key.
Well, we HAVE the following code working but it is NOT inheriting the permissions to the sub key's at all. We are not sure what to do about it. We need the permissions to propagate or else we cannot get all our software working correctly.
does anyone have ANY tips or ideas as to what to do?
Here is the code we have that works but does not do inheritance:
Set dacl = sd.DiscretionaryACL
For Each ace In dacl
If (LCase(ace.trustee) = LCase("BUILTIN\Users")) Then
dacl.RemoveAce ace
End If
Next
sd.DiscretionaryACL = dacl
sec.SetSecurityDescriptor sd
Set ace = CreateObject("AccessControlEntry")
ace.trustee = "BUILTIN\Users"
ace.AccessMask = accMask
ace.AceType = 0
ace.AceFlags = &H2
dacl.AddAce ace
sd.DiscretionaryACL = dacl
sec.SetSecurityDescriptor sd
Set ace = Nothing
Set sd = Nothing
Set dacl = Nothing
Set sec = Nothing
Set sec = CreateObject("ADsSecurity")
Set sd = sec.GetSecurityDescriptor("RGY://" & sRegkey)
Set oDACL = sd.DiscretionaryACL
Set oNewDACL = CreateObject("AccessControlList")
Set oInheritedDACL = CreateObject("AccessControlList")
Set oAllowDACL = CreateObject("AccessControlList")
Set oDenyDACL = CreateObject("AccessControlList")
Set oDenyObjDACL = CreateObject("AccessControlList")
Set oAllowObjDACL = CreateObject("AccessControlList")
For Each oACE In oDACL
If ((oACE.AceFlags And ADS_ACEFLAG_INHERITED_ACE) = ADS_ACEFLAG_INHERITED_ACE) Then
oInheritedDACL.AddAce oACE
Else
Select Case oACE.AceType
Case ADS_ACETYPE_ACCESS_ALLOWED
oAllowDACL.AddAce oACE
Case ADS_ACETYPE_ACCESS_DENIED
oDenyDACL.AddAce oACE
Case ADS_ACETYPE_ACCESS_ALLOWED_OBJECT
oAllowObjDACL.AddAce oACE
Case ADS_ACETYPE_ACCESS_DENIED_OBJECT
oDenyObjDACL.AddAce oACE
End Select
End If
Next
For Each oACE In oDenyDACL
oNewDACL.AddAce oACE
Next
For Each oACE In oDenyObjDACL
oNewDACL.AddAce oACE
Next
For Each oACE In oAllowDACL
oNewDACL.AddAce oACE
Next
For Each oACE In oAllowObjDACL
oNewDACL.AddAce oACE
Next
For Each oACE In oInheritedDACL
oNewDACL.AddAce oACE
Next
Set oInheritedDACL = Nothing
Set oDenyDACL = Nothing
Set oAllowDACL = Nothing
Set oDenyObjDACL = Nothing
Set oAllowObjDACL = Nothing
oNewDACL.AclRevision = oDACL.AclRevision
Set oDACL = Nothing
Set oDACL = oNewDACL
sd.DiscretionaryACL = oDACL
sec.SetSecurityDescriptor sd
Set sd = Nothing
Set sec = Nothing
lSecSetting = getCurrentSec(sRegkey)
.
.
.
Again, if you can help us out you will be my hero! We have alot of programmers who are stummped on this one! Help us out and prove yourself a Computer Guru greater than even most highly skilled programmers!!!
Thank you!
This is the story. I work for a company with over 7,000 computers that are locked down for security reasons so users have VERY limited rights on their computer. This means that some of their programs they need do NOT work since they do not have access to modify data that the program needs to be able to modify.
One of these areas is the system registry. We are working on a tool that will help us automate setting security permissions on said registry key's of the computers at our location.
We have found out how to do many of the functions we require but there are two areas we are 'stuck' on.
1) We need to find a way, if at all possible, to browse our Active Directory schema and select Containers and OU's to apply the automated security fixes on. I know it is possible since they have these api's available from Microsoft but we cannot get it to work correctly with Visual Basic. (I do not choose the programming language, I just do what I am told)
2) This is the biggest problem. We cannot figure out how to use Active Directory Service Interfaces (ADSI) to properly apply security settings on the registry key.
Well, we HAVE the following code working but it is NOT inheriting the permissions to the sub key's at all. We are not sure what to do about it. We need the permissions to propagate or else we cannot get all our software working correctly.
does anyone have ANY tips or ideas as to what to do?
Here is the code we have that works but does not do inheritance:
Set dacl = sd.DiscretionaryACL
For Each ace In dacl
If (LCase(ace.trustee) = LCase("BUILTIN\Users")) Then
dacl.RemoveAce ace
End If
Next
sd.DiscretionaryACL = dacl
sec.SetSecurityDescriptor sd
Set ace = CreateObject("AccessControlEntry")
ace.trustee = "BUILTIN\Users"
ace.AccessMask = accMask
ace.AceType = 0
ace.AceFlags = &H2
dacl.AddAce ace
sd.DiscretionaryACL = dacl
sec.SetSecurityDescriptor sd
Set ace = Nothing
Set sd = Nothing
Set dacl = Nothing
Set sec = Nothing
Set sec = CreateObject("ADsSecurity")
Set sd = sec.GetSecurityDescriptor("RGY://" & sRegkey)
Set oDACL = sd.DiscretionaryACL
Set oNewDACL = CreateObject("AccessControlList")
Set oInheritedDACL = CreateObject("AccessControlList")
Set oAllowDACL = CreateObject("AccessControlList")
Set oDenyDACL = CreateObject("AccessControlList")
Set oDenyObjDACL = CreateObject("AccessControlList")
Set oAllowObjDACL = CreateObject("AccessControlList")
For Each oACE In oDACL
If ((oACE.AceFlags And ADS_ACEFLAG_INHERITED_ACE) = ADS_ACEFLAG_INHERITED_ACE) Then
oInheritedDACL.AddAce oACE
Else
Select Case oACE.AceType
Case ADS_ACETYPE_ACCESS_ALLOWED
oAllowDACL.AddAce oACE
Case ADS_ACETYPE_ACCESS_DENIED
oDenyDACL.AddAce oACE
Case ADS_ACETYPE_ACCESS_ALLOWED_OBJECT
oAllowObjDACL.AddAce oACE
Case ADS_ACETYPE_ACCESS_DENIED_OBJECT
oDenyObjDACL.AddAce oACE
End Select
End If
Next
For Each oACE In oDenyDACL
oNewDACL.AddAce oACE
Next
For Each oACE In oDenyObjDACL
oNewDACL.AddAce oACE
Next
For Each oACE In oAllowDACL
oNewDACL.AddAce oACE
Next
For Each oACE In oAllowObjDACL
oNewDACL.AddAce oACE
Next
For Each oACE In oInheritedDACL
oNewDACL.AddAce oACE
Next
Set oInheritedDACL = Nothing
Set oDenyDACL = Nothing
Set oAllowDACL = Nothing
Set oDenyObjDACL = Nothing
Set oAllowObjDACL = Nothing
oNewDACL.AclRevision = oDACL.AclRevision
Set oDACL = Nothing
Set oDACL = oNewDACL
sd.DiscretionaryACL = oDACL
sec.SetSecurityDescriptor sd
Set sd = Nothing
Set sec = Nothing
lSecSetting = getCurrentSec(sRegkey)
.
.
.
Again, if you can help us out you will be my hero! We have alot of programmers who are stummped on this one! Help us out and prove yourself a Computer Guru greater than even most highly skilled programmers!!!
Thank you!
