Monday, August 18, 2008

SPPrincipal - SPUser - SPWeb.EnsureUser() - SPUtility.ResolvePrincipal()

SPUtility.ResolvePrincipal() method to fetch details about the user by passing "first, last name" or "user email id" or "user login id".

SPPrincipalInfo object is used to hold user details like, first name, last name, email id, login id with domain name.

SPPrincipalInfo userInfo = SPUtility.ResolvePrincipal(objWeb, "loginID", SPPrincipalType.All, SPPrincipalSource.All, null, false);

------------------------------------------------------------------------------------------------

SPWeb.EnsuerUser() will add ther user to site, if the user does not exist and return SPUser object. We can use SPUser object to update "SPUser" field type
Example:
SPUser objUser = objWeb.EnsureUser("domain\\loginname");
item["user"] = objUser;

-----------------------------------------------------------------------------------------------

No comments: