Not able to creat access rule with username


for full reasons around problem, check out http://social.technet.microsoft.com/forums/en-us/fastsharepoint/thread/a3819d84-510e-4292-9fcf-9e3219f12438

but issue boils down difference in outcomes of following 2 statements, both of should generate same access rule object, difference being identityreference:

ps c:\users\garthgrimm> $ar = new-object system.security.accesscontrol.filesystemaccessrule("demo\$sp10tosql", "fullcont
rol", $allinherit, $allpropagation, "allow")
ps c:\users\garthgrimm> $ar


filesystemrights  : fullcontrol
accesscontroltype : allow
identityreference : demo\
isinherited       : false
inheritanceflags  : none
propagationflags  : none

 

ps c:\users\garthgrimm> $ar = new-object system.security.accesscontrol.filesystemaccessrule("demo\username", "fullcontro
l", $allinherit, $allpropagation, "allow")
ps c:\users\garthgrimm> $ar


filesystemrights  : fullcontrol
accesscontroltype : allow
identityreference : demo\username
isinherited       : false
inheritanceflags  : none
propagationflags  : none

unfortunately, identityreference isn't being set correctly in first example.  when full script tries $acl.addaccessrule($ar), throughs error.  ideas on how work around issue?  or causing it?

i'd rewrite part of full script won't have problem when username demo\$demosp10

  $acl = get-acl $keypath$keyname
  $propagation = [system.security.accesscontrol.propagationflags]"none"
  $inherit = [system.security.accesscontrol.inheritanceflags]"none"
  $accessrule = new-object system.security.accesscontrol.filesystemaccessrule($script:username,[system.security.accesscontrol.filesystemrights]::readandexecute, $inherit, $propagation, "allow")
  $acl.addaccessrule($accessrule)
  set-acl -aclobject $acl $keypath$keyname


garth grimm
avery ranch consulting
www.averyranchconsulting.com

try this:

  $ar = new-object system.security.accesscontrol.filesystemaccessrule("demo\`$sp10tosql", "fullcontrol", $allinherit, $allpropagation, "allow")  



if found post helpful, please "vote helpful". if answered question, remember "mark answer".

rich prescott | mcitp, mcts, mcp

[blog] engineering efficiency | [twitter] @rich_prescott | [powershell gui] client system administration tool


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

CRL Revocation always failed

Failed to query the results of bpa xpath

0x300000d errors in Microsoft Remote Desktop client