Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set the permission folder

Status
Not open for further replies.

Gianricus

Programmer
Apr 2, 2003
62
IT
Hi, i have created one program that the Sales-Man save the Order generate on the server 5 forlder:

-Sales
-Quality
-Admin
-Eng
-Purch

O.S. on the server is win NT4 and the user have win 98.

the problem is that when the Sales-man generate the folder, i want set
the permission.

Sales at group "Sales"
Quality at group "QC"
etc.

is possible set the permission from code?

Thanks
 
xcalcs is an external program that can do this, from code you could use

Set sec = CreateObject("ADsSecurity")
'the adssecurity.dll is part of the adsi resource kit avail from MS
 
here is a ms example using vbscript, sorry if there are environment strings

Const ADS_RIGHT_GENERIC_READ = &H80000000
Const ADS_RIGHT_GENERIC_EXECUTE = &H20000000
Const ADS_ACETYPE_ACCESS_ALLOWED = 0

Set sec = CreateObject("ADsSecurity")

Set sd = sec.GetSecurityDescriptor("FILE://c:\public\specs")
Set dacl = sd.DiscretionaryAcl

'-- Show the ACEs in the DACL ----
For Each ace In dacl
wscript.echo ace.Trustee
wscript.echo ace.AccessMask
wscript.echo ace.AceType
Next

Set ace = CreateObject("AccessControlEntry")
ace.Trustee = "ARCADIABAY\jsmith"
ace.AccessMask = ADS_RIGHT_GENERIC_READ Or ADS_RIGHT_GENERIC_EXECUTE
ace.AceType = ADS_ACETYPE_ACCESS_ALLOWED

dacl.AddAce ace
sd.DiscretionaryAcl = dacl
sec.SetSecurityDescriptor sd
 
your code is very useful, but where i set the group permission of the folder?

Thanks
 
Set ace = CreateObject("AccessControlEntry")
ace.Trustee = "YOUR_DOMAIN\SALES" '######## NB
ace.AccessMask = ADS_RIGHT_GENERIC_READ Or ADS_RIGHT_GENERIC_EXECUTE
ace.AceType = ADS_ACETYPE_ACCESS_ALLOWED

dacl.AddAce ace
sd.DiscretionaryAcl = dacl
sec.SetSecurityDescriptor sd
 
the below might be of more use to you.
pass the sub a string to the folder and an array or hash table of the groups you want to set permissions for.
you might want to add another argument for the type of access.
you might not need the:
sd.DiscretionaryAcl = dacl
sec.SetSecurityDescriptor sd
in the loop but i am not sure.

Sub setPermissions(strFolder, dicGroups)

Const ADS_RIGHT_GENERIC_READ = &H80000000
Const ADS_RIGHT_GENERIC_EXECUTE = &H20000000
Const ADS_ACETYPE_ACCESS_ALLOWED = 0

Set sec = CreateObject("ADsSecurity")

Set sd = sec.GetSecurityDescriptor("FILE://" & strFolder)
Set dacl = sd.DiscretionaryAcl

For Each aKey In dicGroups
Set ace = CreateObject("AccessControlEntry")
ace.Trustee = "ARCADIABAY\" & CStr(aKey)
ace.AccessMask = ADS_RIGHT_GENERIC_READ Or ADS_RIGHT_GENERIC_EXECUTE
ace.AceType = ADS_ACETYPE_ACCESS_ALLOWED

dacl.AddAce ace
sd.DiscretionaryAcl = dacl
sec.SetSecurityDescriptor sd
Next
 
I recive this error in this line of code:

Set Sec = CreateObject("ADsSecurity")

The ActiveX component don't create the object

Why?
How can use the adssecurity.dll? Where i can find that?
Thanks
 
ADsSecurity.DLL is part of the Active Directory Services Interfaces (ADSI), which you won't have if you are running NT4. Nor will it work on W95/98/Me.

On the surface, therefore, it would appear that mrmovie's solution is inappropriate in your case since you clearly state your target platforms are NT4 and W98. However, if you want to use this solution (and trust me it's more straightforward than the API method that would otherwise be required) try
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top