tags:

views:

46

answers:

3

I am using sharepoint 3.0 and I do the following:
1. Create a user in the server
2. Go to sharepoint site and associate a group with this newly created user (I could not use common name of user to search for the user, I had to use the login name :S)
3. Create an item in one of the list and use this user
4. Login to the site with this user
5. Reset IIS

Problem: In a console application that is running in server, I call SPWeb.AllUsers and it is only returning old users that were there from past(for example administrator) and not returning this newly created user. What part of the puzzle am I missing?

+2  A: 

Try SPWeb.SiteUsers that returns users that are added to site collection.

SPWeb.Users return you users that are only explicitly added to that web (unique permissions), however SPWeb.AllUsers give you SPWeb.Users + those that have visited that web.

Janis Veinbergs
+1  A: 

You could also try the SPWeb.EnsureUser() method to check whether the user actually exists. Furthermore, users are stored in a hidden list in Sharepoint that's accessible only to site admins. More info on that here.

Colin
The users list is simply hidden, but everyone has read access to it. It is possible to query that list using web services or SharePoint API from a regular user's account. The only problem is that you have to know the GUID of that list (and regular users cannot see the list in SPWeb.Lists collection)
naivists
By accessible i mean write access of course :-D.
Colin
A: 

Hi,

To know more about the differences between SPWeb.Users, SPWeb.AllUsers, SPWeb.SiteUsers check out this link:

http://prasanjitmandal.blogspot.com/2010/05/difference-between-spwebusers.html

Hope this helps

Prasanjit Mandal