.NET Server

Programming .NET WebDAV Server Authentication and Authorization

In this article

Programming .NET WebDAV Server Authentication and Authorization

You can limit user ability to browse, save documents, create folders, etc inside your WebDAV Server interfaces implementation. To limit browsing you can filter documents in your IFolderAsync.GetChildrenAsync() method implementation and return only items that the user has permissions to see. Please see "IItemCollectionAsync" section here:

Inside your interfaces implementation you can check if the user has enough permissions in the following methods:

Read file - IContentAsync.ReadAsync
New Folder - IFolderAsync.CreateFolderAsync
Delete Folder - IHierarchyItemAsync.DeleteAsync
New File - IFolderAsync.CreateFileAsync
Edit File - First the client app typically locks the document calling ILockAsync.LockAsync and than calls IContentAsync.WriteAsync. Please find more info here:

Typically you will throw a DavException exception to indicate that the user does not have permissions. For example:

1 2 3 4 5 6 7 8 public Task CreateFolderAsync(string name) { if(HttpContext.Current.User.Identity.Name != "User1") { throw new DavException("No Write Permission.", DavStatus.FORBIDDEN); } ... }

Also it make sense to check permissions in other methods: IHierarchyItemAsync.CopyToAsync, IHierarchyItemAsync.MoveToAsync, IHierarchyItemAsync.UpdatePropertiesAsync, ILockAsync.RefreshLockAsync.

The Engine will process it and return a WebDAV error description to the client. Please note that Windows Explorer (which is in fact Microsoft Mini-redirector driver behind the scenes) and MS Office swallows any error descriptions returned by the server and displays just a generic error message.