ADsSecurit Folders permissions

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
 
F

Fay

I don't know this for sure, but I would expect that you
can't use AD Security settings without running AD on your
domain. What would manage these settings to implement
them? User rights & NTFS permissions are handled via
built in windows security. Windows security does not
manage AD, that's what AD is for. Why not run AD if you
wish to use it's security? But like I said, I could be
wrong. :)
-----Original Message-----
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
 
V

Versteijn

Fay said:
I don't know this for sure, but I would expect that you
can't use AD Security settings without running AD on your
domain. What would manage these settings to implement
them? User rights & NTFS permissions are handled via
built in windows security. Windows security does not
manage AD, that's what AD is for. Why not run AD if you
wish to use it's security? But like I said, I could be
wrong. :)

Add a reference to Active DS (COM Interop) to your project and see
http://www.codeproject.com/dotnet/adduseracetofile.asp for further
instructions ;)

good luck

Freek Versteijn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top