A
Andy
Hello,
I want to know,how I can set permission for a user or a group on folder using ADSI , ADsSecurity.dll with VB.net or C#.
I tried some samples but nothing works.
I'm using Windows 2000, VS.NET 2003, I have AdsSecurity.dll in my SYS32 but my computer is not on AD
but I always have an error at line (objSecDes.DiscretionaryAcl = objDAcl)
Public Sub SetPermissions()
Dim objDAcl As AccessControlList
Dim objAce2 As AccessControlEntry
Dim objADsSec As ADsSecurity
Dim objSecDes
Try
objADsSec = New ADsSecurity
objSecDes = CType(objADsSec.GetSecurityDescriptor("FILE://" & \\myServer\c$\test1), SecurityDescriptor)
objDAcl = CType(objSecDes.DiscretionaryAcl, AccessControlList)
objAce2 = New AccessControlEntry
objAce2.Trustee = "Bozo"
objAce2.AccessMask = ADS_RIGHT_GENERIC_ALL
objAce2.AceType = ADS_ACETYPE_ACCESS_ALLOWED
objAce2.AceFlags = ADS_ACEFLAG_INHERIT_ACE Or ADS_ACEFLAG_INHERIT_ONLY_ACE Or 1
objDAcl.AddAce(objAce2)
objSecDes.DiscretionaryAcl = objDAcl
objADsSec.SetSecurityDescriptor(objSecDes)
Catch ex As Exception
Throw ex
End Try
end sub
I want to know,how I can set permission for a user or a group on folder using ADSI , ADsSecurity.dll with VB.net or C#.
I tried some samples but nothing works.
I'm using Windows 2000, VS.NET 2003, I have AdsSecurity.dll in my SYS32 but my computer is not on AD
but I always have an error at line (objSecDes.DiscretionaryAcl = objDAcl)
Public Sub SetPermissions()
Dim objDAcl As AccessControlList
Dim objAce2 As AccessControlEntry
Dim objADsSec As ADsSecurity
Dim objSecDes
Try
objADsSec = New ADsSecurity
objSecDes = CType(objADsSec.GetSecurityDescriptor("FILE://" & \\myServer\c$\test1), SecurityDescriptor)
objDAcl = CType(objSecDes.DiscretionaryAcl, AccessControlList)
objAce2 = New AccessControlEntry
objAce2.Trustee = "Bozo"
objAce2.AccessMask = ADS_RIGHT_GENERIC_ALL
objAce2.AceType = ADS_ACETYPE_ACCESS_ALLOWED
objAce2.AceFlags = ADS_ACEFLAG_INHERIT_ACE Or ADS_ACEFLAG_INHERIT_ONLY_ACE Or 1
objDAcl.AddAce(objAce2)
objSecDes.DiscretionaryAcl = objDAcl
objADsSec.SetSecurityDescriptor(objSecDes)
Catch ex As Exception
Throw ex
End Try
end sub