I got an user name, how can I get the group name of the user programmatically?
View Complete Post
I would like to create SPSite object and pass user token as an argument to make sure all operations are executed with SharePoint security trimming. Inside SPSite I am reading some file content using File.OpenBinaryStream() method.
I am not sure if there is a way to create SPUser using user credentials. I am able to get SPUser by getting it from SPWeb.AllUsers collection using user login name. However it doesn't work for claims based sites as login name for these users looks like i:0#.w|domain\username.
Am I allowed to user code like this:
SPUser user = web.AllUsers["i:0#.w|domain\username"];
to get SPUser object? I know that 'w' from 'i:0#.w' string means that it is Windows user. What do other symbols mean? Is there any method which can generate login name from user credentials so I may use it to get SPUser from AllUsers collection?
Possibly there are some other ways to execute code for SPSite under some SharePoint user privileges?
P.S. All my code is running out of SharePoint context. I have tried to user windows impersonation but got Access Denied error.
Thanks beforehand for any help,
I try to change some usermapping in my SharePoint Foundation Farm with the following command in the powershell:
move-spuser -IgnoreSID -Identity ADD\M45443 -NewAlias ADI\M45443
move-spuser -IgnoreSID -Identity "ADD\M45443" -NewAlias "ADI\M45443"
Unfortunately I get this errormessage:
Move-SPUser : The parameterless Read method can only be used when this instance was initialized with an SPUser object.
At line:1 char:12
+ Move-SPUser <<<< -Identity "ADD\M45443" -NewAlias "ADI\M45443"
+ CategoryInfo : InvalidData: (Microsoft.Share...PCmdletMoveUser:
SPCmdletMoveUser) [Move-SPUser], InvalidOperationException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletMoveUser
Do you have any idea what's wrong with my command?
Thanks in advance