Click here to Skip to main content
16,012,168 members
Home / Discussions / C#
   

C#

 
GeneralRe: thread safety using Interlocked Pin
George_George16-May-08 20:14
George_George16-May-08 20:14 
GeneralRe: thread safety using Interlocked Pin
Guffa17-May-08 9:22
Guffa17-May-08 9:22 
GeneralRe: thread safety using Interlocked Pin
George_George17-May-08 21:21
George_George17-May-08 21:21 
GeneralRe: thread safety using Interlocked Pin
Guffa18-May-08 12:54
Guffa18-May-08 12:54 
GeneralRe: thread safety using Interlocked Pin
George_George19-May-08 2:30
George_George19-May-08 2:30 
Questionhow access to a fild in a record in data grid ? [modified] Pin
bizhanmp15-May-08 22:42
bizhanmp15-May-08 22:42 
AnswerRe: how access to a fild in a record in data grid ? Pin
Sacha Barber16-May-08 1:02
Sacha Barber16-May-08 1:02 
GeneralPowerShell Query Pin
Kevin McFarlane15-May-08 22:24
Kevin McFarlane15-May-08 22:24 
I know this is not C# but I figure there's more likely to be people in this forum that have played with PowerShell.

I've been experimenting with a couple of scripts to set folder permissions and I'm getting nowhere fast.

I've tried this from here http://chrisfederico.wordpress.com/2008/02/01/setting-acl-on-a-file-or-directory-in-powershell/[^]:

$acl = Get-Acl c:\temp
$permission = "domain\user","FullControl","Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($accessRule)
$acl | Set-Acl c:\temp

and this from here http://technet.microsoft.com/en-us/magazine/cc194419.aspx[^]:

#ChangeACL.ps1
$Right="FullControl"

#The possible values for Rights are
# ListDirectory, ReadData, WriteData
# CreateFiles, CreateDirectories, AppendData
# ReadExtendedAttributes, WriteExtendedAttributes, Traverse
# ExecuteFile, DeleteSubdirectoriesAndFiles, ReadAttributes
# WriteAttributes, Write, Delete
# ReadPermissions, Read, ReadAndExecute
# Modify, ChangePermissions, TakeOwnership
# Synchronize, FullControl

$StartingDir=Read-Host "What directory do you want to start at?"
$Principal=Read-Host "What security principal do you want to grant" `
"$Right to? `n Use format domain\username or domain\group"

#define a new access rule.
#note that the $rule line has been artificially broken for print purposes.
#it needs to be one line. the online version of the script is properly
#formatted.
$rule=new-object System.Security.AccessControl.FileSystemAccessRule
($Principal,$Right,"Allow")

foreach ($file in $(Get-ChildItem $StartingDir -recurse)) {
$acl=get-acl $file.FullName

#Add this access rule to the ACL
$acl.SetAccessRule($rule)

#Write the changes to the object
set-acl $File.Fullname $acl
}

For the second one I get this error when trying to apply it to an inetpub folder:

Exception calling "SetAccessRule" with "1" argument(s): "Some or all identity references could not be translated."
At C:\Documents and Settings\kmcfarlane\My Documents\Development\ChangeACL.ps1:29 char:21
+ $acl.SetAccessRule( <<<< $rule)
Set-Acl : The security identifier is not allowed to be the owner of this object.
At C:\Documents and Settings\kmcfarlane\My Documents\Development\ChangeACL.ps1:32 char:10
+ set-acl <<<< $File.Fullname $acl

For the first script I just get the first part of that error. Any ideas?


Kevin

GeneralRe: PowerShell Query Pin
ChrisKo16-May-08 7:36
ChrisKo16-May-08 7:36 
GeneralRe: PowerShell Query Pin
Kevin McFarlane16-May-08 8:13
Kevin McFarlane16-May-08 8:13 
QuestionControl for handling a lot of Images Pin
anderslundsgard15-May-08 22:09
anderslundsgard15-May-08 22:09 
AnswerRe: Control for handling a lot of Images Pin
Christian Graus15-May-08 22:58
protectorChristian Graus15-May-08 22:58 
GeneralRe: Control for handling a lot of Images Pin
anderslundsgard15-May-08 23:44
anderslundsgard15-May-08 23:44 
QuestionFileStream object and performance concern Pin
rcollina15-May-08 21:30
rcollina15-May-08 21:30 
AnswerRe: FileStream object and performance concern Pin
ChrisKo16-May-08 7:35
ChrisKo16-May-08 7:35 
AnswerRe: FileStream object and performance concern Pin
The Nightcoder16-May-08 11:49
The Nightcoder16-May-08 11:49 
AnswerRe: FileStream object and performance concern Pin
rcollina16-May-08 21:37
rcollina16-May-08 21:37 
Questionhow can i make an appointment schedulling in c# Pin
mjee15-May-08 20:53
mjee15-May-08 20:53 
QuestionRe: how can i make an appointment schedulling in c# Pin
sunspeed15-May-08 20:55
sunspeed15-May-08 20:55 
AnswerRe: how can i make an appointment schedulling in c# Pin
mjee15-May-08 21:26
mjee15-May-08 21:26 
GeneralRe: how can i make an appointment schedulling in c# Pin
Rupesh Kumar Swami15-May-08 21:45
Rupesh Kumar Swami15-May-08 21:45 
GeneralRe: how can i make an appointment schedulling in c# Pin
sunspeed15-May-08 21:47
sunspeed15-May-08 21:47 
GeneralRe: how can i make an appointment schedulling in c# Pin
Shani Natav15-May-08 22:03
Shani Natav15-May-08 22:03 
AnswerRe: how can i make an appointment schedulling in c# Pin
J4amieC15-May-08 22:24
J4amieC15-May-08 22:24 
QuestionMultithreading in streaming media Pin
B!Z15-May-08 20:31
B!Z15-May-08 20:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.