I have a string "System Account", how can I convert the string into SPUser?
I've tried SPContext.Current.Web.EnsureUser("System Account") and also web.AllUser["System Account"] but hit error.
Please help, thank you in advanced.
|
I have a string "System Account", how can I convert the string into SPUser? I've tried SPContext.Current.Web.EnsureUser("System Account") and also web.AllUser["System Account"] but hit error. Please help, thank you in advanced. |
|||
|
|
You can retrieve the system account by SPSite property
Basicaly EnsureUser method uses logon name (Domain\User_Alias) of the user. |
|||||||
|
|
i guess you are looking for some api to resolve inputs. try this utility method:
it will return a SPPrincipal object, witch contains a "LoginName" property. then you can use SPWeb.EnsureUser(loginName) to get a SPUser object. more infomation about this method: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.resolveprincipal.aspx |
|||
|
|
|
Try this, should work
plus can someone tell me how to do it if there is a domain user? |
|||
|