Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User Permission Mask from NetworkCredentials

Although I am currently developing this WinForms application on our Sharepoint server I intend for the finished program to function from any computer on the Domain. I'm using the WSS web services to get all the information I use from Sharepoint.

I have written some code which will check Sharepoint Permission masks, with logical OR against mask, for all the permissions it covers but I am having trouble returning the Sharepoint mask for the current user. I would like users to be able to log right in through Windows Authentication so this was my immediate idea.

NetworkCredential credentails = CredentialCache.DefaultNetworkCredentials;
var userInfo = userGroupService.GetUserInfo(credentails.UserName);

However although I am able to return the permission collection for the entire Sharepoint site with DefaultNetworkCredentials (as in bellow snippet) the properties are empty strings, so I can't use it to get the UserName.

permissionService.Credentials = CredentialCache.DefaultNetworkCredentials;
permissionService.Url = "http://localhost/mySite/_vti_bin/Permissions.asmx";
// Web service request works
XmlNode node = permissionService.GetPermissionCollection(siteName, "Web");
// But I need to identify current user from this collection somehow still

I read that Windows Authentication suffers from a double-hop issue, which I want to avoid, but as I am developing on the server Sharepoint & IIS are running, I can't see this causing an immediate issue.

Is there a way around this or a better way to get the current users permission mask?

like image 899
Amicable Avatar asked Dec 14 '25 06:12

Amicable


1 Answers

If the current user for wss will always be the same as the user currently logged on to the pc

var userInfo = userGroupService.GetUserInfo(Environment.UserDomainName +@"\"+ Environment.UserName);

or to get the permissions for the currently logged on user

XmlNode currentUserPermission = userGroupService.GetRolesAndPermissionsForCurrentUser();
like image 144
Aquila Sands Avatar answered Dec 15 '25 19:12

Aquila Sands



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!