Wednesday, October 7, 2009

c# difference between the CurrentUser and AllUsers["username"] in sharepoint

When I am trying to retrieve the sharepoint site sign in user details from SharePoint Peoples and user group, I have faced some confusions as discussed below.

For example consider that we need the email address of the current user.According to my requirement i used property shown below

SPContext.Current.Web.CurrentUser.EMail returns only the current Sign in User email address

and CurrentWeb.AllUsers[Properties.UserLoginName].Email also returns email address.

AllUsers returns all users who are either members of the site or who have browsed to the site as authenticatedmembers of the domain group in the site.

CurrentUser returns only the current sign in user details.

Conclusion:

  1. If we want to current user details, we can use both properties as shown above.
  2. If we want the user details of particular user other than current user we need to use the AllUsers property.

1 comment:

electronic signatures said...

That's really good stuff. My buddies at work will definitely be awestruck ! Thanks for sharing.