Monday, January 14, 2008

Error: “Cannot find the path specified” when adding role assignments

If you ever get the error “The system cannot find the path specified. (Exception from HRESULT: 0x80070003)” while adding role assignments to a library or web in SharePoint, then this might help you solve your problem… I was trying to add role assignments to a library (using library.RoleAssignments.Add(newRole)), which had already worked perfectly before, but when trying it this time, I got the error I’ve mentioned before. The key to solving my issue was something that didn’t include paths at all: I just forgot to break the role inheritance of my library. So if you ever encounter this error, just add the following lines, they will most probably solve your issue:

library.BreakRoleInheritance(true);
library.Update();

4 comments:

Marius said...

I got the same error: "The system cannot find the path specified. (Exception from HRESULT: 0x80070003)", but for me these lines was not enough:
library.BreakRoleInheritance(true);
library.Update();

I tried to add ResetRoleInheritance();, and then it worked. So all looks like that:
lstList.ResetRoleInheritance();
library.BreakRoleInheritance(true);
library.Update();

Tom said...

Thanks for your reply Marius, it might help other people facing this problem!

Alex said...

Thank you very much for this post and for the reply Marius ... it saved my day :)

Anonymous said...

totally random indeep! My code was working perfectly fine. All of a sudden (don know if it had anything to do with MOSS SP2 install), but started seing this error.

I already had:
library.BreakRoleInheritance(false); //dont want to copy perms from parent
library.Update();

So I had to add the ResetRoleInheritance line to get past this issue.

But for some reason, I still dont see my timer job running. I see it in the operations page, but see some stack trace on
Stack: at Microsoft.SharePoint.Administration.SPPersistedObject.Update()

not sure WTF thats about!