I have a service that runs on the save server as SharePoint. I can use this service to upload/move files in document libraries on different SharePoint sites. I am now trying to check if a user (DOMAIN\USER) has permissions to access a particular SharePoint site.
I have tried using the following:
web.EnsureUser("DOMAIN\USER")
web.CheckPermissions(SPBasePermissions.Open)
The above should raise UnauthorizedAccessException if the user has no permissions. For me it never raises any exception although that user does not have permissions to access this particular site (verified by trying to access the site on the user's machine - Unauthorized 401)
web.DoesUserHavePermissions("DOMAIN\USER", SPBasePermissions.Open)
The above should return True or False, but for me it always returns False, also when the user has permissions to access a site (verified by accessing the site on the user's machine - OK 200).
web.GetUserEffectivePermissions("DOMAIN\USER")
The above should return the permissions mask, but it always returns an EmptyMask.
I think I do not understand those methods, but they are not described well anywhere on the Internet.
Does anyone know how I can check if a user has permissions necessary to access a SharePoint site?