SharePoint User Group UK

Share the knowledge!

Welcome to SharePoint User Group UK Sign in | Join | Help
in
Home Blogs Forums Photos Files Roller

user/staff listing in Windows Sharepoint Services

Last post 08-21-2007, 3:50 PM by dhunter. 6 replies.
Sort Posts: Previous Next
  •  08-10-2007, 10:57 AM 4756

    user/staff listing in Windows Sharepoint Services

    Hi,

    I'm working on converting our existing bespoke straight ASP intranet over to Sharepoint, I'm using WSS for budgetary reasons, and while I'm very impressed with Sharepoint generally, I've one problem area that I would really welcome assistance with.

    Our existing intranet has a database-derived staff listing, with phone/email/job title info, and I want to implement a similiar listing in Sharepoint.  We are planning to use Windows authenticaton.  I've added a few Windows users to Sharepoint, filled in the various columns in the People and Groups page (Name, Title, About Me etc etc) but how can a produce a staff listing based on this data - I know WSS doesn't have a user profile database, but this info is obviously stored somewhere?  I really need programmatic access to these fields..

    I've considered using forms authentication (and storing the contact data in a database) but it seems using forms authentication will break other functionality (search/office integration) so I'm reluctant to go down that route.  Using MOSS will greatly add to our costs (we're a charitable organisation) so I'm keen to explore other possibilities first.

    Really grateful for any advice.

    James Drever.
    Field Studies Council.
  •  08-10-2007, 4:49 PM 4766 in reply to 4756

    Re: user/staff listing in Windows Sharepoint Services

    Hi James,

    The user information in WSS V3 is stored in a special list called "User Information List".  You can only access this programatically.  For example:

    // assumes you have SharePoint context and the top level web

    // retrieve an instance of the user information list
    Microsoft.SharePoint.SPList list = web.Lists["User Information List"];

    // get the target user
    Microsoft.SharePoint.SPUser user = web.SiteUsers[“domain\\username”];

    // get the list item for the target user
    Microsoft.SharePoint.SPListItem userInfo = list.Items.GetItemById(user.ID);

    // get the property value
    string propertyValue = userInfo["PropertyName"].ToString();

    Hope this helps

    Dave


    My SharePoint Blog http://www.davehunter.co.uk
  •  08-14-2007, 10:26 AM 4805 in reply to 4766

    Re: user/staff listing in Windows Sharepoint Services

    Thanks very much for the helpful reply, Dave.

    Having managed to get search working with forms authentication, I've decided to sacrifice the finer points of Sharepoint/Office integration and go with forms authentication.  But its really handy to know how to get access to the User Information List, because it is so poorly documented elsewhere.
  •  08-14-2007, 3:21 PM 4817 in reply to 4756

    Re: user/staff listing in Windows Sharepoint Services

    Hi,
    I've just started looking at a similar task;  i'm after a user list and an "in/out" status that the users assign themselves.  Ideally i don't want to have to code this, instead hope to utilise SP and Designer.

    The user list is simple enough, just plug a datasource into one of the numerous UserProfile tables. The Shared Services table gives NT Name, email address and manager etc. 

    However, my custom "Whereabouts" field that has been created in the Profile Properties page on SharedServices is more elusive.  I'm still trying to find the data store for Profile Properties which has all the AD and SP details required.

    Any pointers gratefully received

    Pete


    Nothing is as it seems, nor is it otherwise.
  •  08-14-2007, 3:53 PM 4818 in reply to 4817

    Re: user/staff listing in Windows Sharepoint Services

    Hi Pete,

    Sounds like your using MOSS and the User Profiles.  I hope your not querying the database tables as this is unsuported by Microsoft.  You should write a web part and use the API to query the values for the current user.  The following code gets the current user's profile and the in/out status.

    // get the current site
    SPSite site = SPControl.GetContextSite(HttpContext.Current);

    // get the current user
    SPUser currentUser = site.RootWeb.CurrentUser;

    // get the server context and user profile manager
    ServerContext context = ServerContext.GetContext(site);
    UserProfileManager profileManager = new UserProfileManager(context);

    // get the user profile for the current user
    UserProfile profile = profileManager.GetUserProfile(currentUser.LoginName);

    string inoutstatus = profile["inoutstatus"].toString();

    You can set values by using profile["inoutstatus"] = "out"; and use profile.Commit(); to save

    Hope this helps

    Dave


    My SharePoint Blog http://www.davehunter.co.uk
  •  08-20-2007, 3:06 PM 4947 in reply to 4818

    Re: user/staff listing in Windows Sharepoint Services

    Cheers Dave,
    I had seen the methods for getting the user details you mentioned but not the variable for "inoutstatus" so thanks for that !  look forward to testing it out soon.

    I'm very new to both  SP as well as C# and don't even have my development environment set up for Visual Studio - currently reading all the blogs and sites on VPC and VMWare (but that's a whole other licensing nightmare)  whilst trying SP out of the box stuff. 

    Thanks for the tip and quick response !
    Pete


    Nothing is as it seems, nor is it otherwise.
  •  08-21-2007, 3:50 PM 4972 in reply to 4947

    Re: user/staff listing in Windows Sharepoint Services

    Hi Pete,

    The "inoutstatus" was just an example of retrieving the property you created in the user profile.  The syntax

    string propertyValue = profile["NameOfTheProperty"].toString();

    "NameOfTheProperty" could be replaced with the name of any custom property you have created in the user profile.

    Hope this makes sense

    Dave


    My SharePoint Blog http://www.davehunter.co.uk
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems