Ask a Question related to ASP.NET Security, Design and Development.
-
Shawn H. Mesiatowsky #1
Change NTFS Permissions or run shell script
I am trying to Create a web app that creates a directory, and assigns
permissions to the directory. Is there a way to do this, or even run a shell
comand (like cacls.exe) to alter the NTFS permissions on the directory?
Thanks for your help
Shawn H. Mesiatowsky
Shawn H. Mesiatowsky Guest
-
user permissions on NTFS
I have flash working for local and domain admins but not to anyone else.The only way I've got round to this is to make users admintrators of the... -
Changing NTFS permissions in ASP.NET
Hi. Some related questions were discussed here, but my question is some different. I'm writing the project, the metter of it can be expressed... -
NTFS permissions
I need to reset the NTFS permissions of a windows 2003 web server to the default installation permissions. What's the easiest way of doing this?... -
NTFS permissions for ASP.NET user
I've read the following article regarding NTFS permissions and ASP.NET http://msdn.microsoft.com/library/default.asp?... -
PHP & NTFS Permissions
Hello group! I'm having a problem and I hope some of you may be able to point me in the right direction. I inherited a web site using php,... -
Daniel Fisher\(lennybacon\) #2
Re: Change NTFS Permissions or run shell script
Look at the System.IO namespace and the Directory class.
It's not easy to set the permissions if you do not use .NET 2.0 yet. There
is a Win32 wrapper class around gotDotNet.com you can try.
The namespace System.Diagnostics holds a class called ProcessInfo witch can
be used to run "calcs.exe" for example.
--
Daniel Fisher(lennybacon)
MCP ASP.NET C#
Blog: [url]http://www.lennybacon.com/[/url]
"Shawn H. Mesiatowsky" <smesiatowsky@spam_no_perfectfit-ind.com> wrote in
message news:%23l0tj7jCFHA.2232@TK2MSFTNGP14.phx.gbl...>I am trying to Create a web app that creates a directory, and assigns
>permissions to the directory. Is there a way to do this, or even run a
>shell comand (like cacls.exe) to alter the NTFS permissions on the
>directory? Thanks for your help
>
> Shawn H. Mesiatowsky
>
Daniel Fisher\(lennybacon\) Guest
-
Vladimir #3
RE: Change NTFS Permissions
' Setting NTFS permissions
' Creating Access Control Entry (ACE) object
Function SetACE(AccessMask, AceFlags, AceType, objTrustee)
Set objACE = getObject("Winmgmts:Win32_Ace").Spawninstance_
objACE.AccessMask = AccessMask
objACE.AceFlags = AceFlags
objACE.AceType = AceType
objACE.Trustee = objTrustee
Set SetACE = objACE
End Function
Wscript.Echo "Script running ..."
Set objs = GetObject("Winmgmts:").InstancesOf("Win32_AccountS ID")
For Each obj In objs
strValue = obj.Properties_("Element") ' object refrence
Set objElement = GetObject("Winmgmts:"+strValue) ' getting object
strName = objElement.Properties_("Name")
If strName = "TinaTurner" Then ' that's it
Exit For
End If
Next
' Getting SID
strValue = obj.Properties_("Setting")
Set objSid = GetObject("Winmgmts:"+strValue)
BinaryRepresentationOfSid = objSid.Properties_("BinaryRepresentation")
' Group "All"
Set objTrusteeAll = getObject("Winmgmts:Win32_Trustee").SpawnInstance_
objTrusteeAll.SID = Array(1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0)
' User GeorgeSmith
Set objTrusteeTT = GetObject("Winmgmts:Win32_Trustee").SpawnInstance_
objTrusteeTT.SID = BinaryRepresentationOfSid
' Setting NTFS permissions ...
Set Ace = SetACE(2032127, 3, 0, objTrusteeAll) ' full access
Set objSecDescriptor =
GetObject("Winmgmts:Win32_SecurityDescriptor").Spa wnInstance_
objSecDescriptor.DACL = Array(Ace)
' One folder
folderName = "C:\Data\"
Set obj = GetObject("Winmgmts:Win32_Directory='" & folderName & "'")
Set objClass = GetObject("Winmgmts:Win32_Directory")
Set objInParam =
obj.Methods_("ChangeSecurityPermissions").inParame ters.SpawnInstance_
objInParam.Option = 4 'DACL
objInParam.SecurityDescriptor = objSecDescriptor
Set objOutParams = obj.ExecMethod_("ChangeSecurityPermissions", objInParam)
Wscript.Echo folderName & " ..."
If objOutParams.ReturnValue = 0 Then
str = "... changed"
Else
str = "Error!" & vbCrLf & " ReturnValue = " & objOutParams.ReturnValue
End if
Wscript.Echo str
' Another folder
Set Ace1 = SetACE(1179817, 3, 0, objTrusteeAll) ' read
Set Ace2 = SetACE(2032127, 3, 0, objTrusteeTT) ' full
Set objSecDescriptor =
GetObject("Winmgmts:Win32_SecurityDescriptor").Spa wnInstance_
objSecDescriptor.DACL = Array(Ace1, Ace2)
folderName = "C:\Data\Accounting"
Set obj = GetObject("Winmgmts:Win32_Directory='" & folderName & "'")
Set objClass = GetObject("Winmgmts:Win32_Directory")
Set objInParam =
obj.Methods_("ChangeSecurityPermissions").inParame ters.SpawnInstance_
objInParam.Option = 4 'DACL
objInParam.SecurityDescriptor = objSecDescriptor
Set objOutParams = obj.ExecMethod_("ChangeSecurityPermissions", objInParam)
Wscript.Echo folderName & " ..."
If objOutParams.ReturnValue = 0 Then
str = "... changed"
Else
str = "Error!" & vbCrLf & " ReturnValue = " & objOutParams.ReturnValue
End if
Wscript.Echo str
Wscript.Echo "Finish"
Vladimir Guest



Reply With Quote

