locked
how i get user information from user that apperance in browse "serch people in Directory Service"?. RRS feed

  • Question

  • Hello, I made a feuter in sharepoint 2007 and I need to get user information from user that apperance in browse "serch people in Directory Service", but i have 2 problems:

    1. the field E-Mail, not retrive , but it exists.

    2. Not All user are founded but they can see themselves in the "Search people", Why?, I don Understand.

    Thanks.

     

    My Code:

     

    string

    [] IdUser;

     

    if (properties.ListTitle == "Comit de Categora")

    {

     

    SPListItem Item = properties.ListItem;

     

    IdUser =

    new string[2];

    IdUser = Item[

    "persona"].ToString().Split(';');

     

    #region

    buscando el usuario

     

    using (SPSite Site = new SPSite("http://pekaqpsrv622:2000/abastecimiento"))

    {

     

    //ServerContext object current site
     

     

    ServerContext context = ServerContext.GetContext(Site);

     

    //UserProfileManager object to access MOSS user profiles

     

    UserProfileManager profileManager = new UserProfileManager(context);

     

    //Find the user profile of given account name

    IdUser[1] = IdUser[1].Replace(

    "#", "");

     

    UserProfile user = profileManager.GetUserProfile(IdUser[1]); //Not all user are founder why?.

    Item[

    "Correo elctrnico"] = user["E-Mail"];//no retrive nothing, but there is email, i don know if the name of field is correct.

    Item[

    "Cargo2"]=user["Title"];

    Item[

    "Departamento"] = user["Department"];

    Item.Update();

    }

    #endregion

     

     

     

    Tuesday, August 9, 2011 12:53 AM

Answers

All replies

  • Hi, i'm very new in sharepoint 2007, and i stand in this sitution, i have a site in sharepoint which it have a list of users, when i add the user in the list, i access  to form where i should search users in the active directory, when a choose one and press ok, it load the names and i have to complet also information how email, department and job althrough  this information being in the look up from active directory and the question is: How do i make to this information email, department and job, pass automatically to form???. Please excuse me my inglish.
    • Moved by Mike Walsh FIN Friday, August 5, 2011 6:14 AM admin q ("programmatically" not stated) (From:SharePoint - Development and Programming (pre-SharePoint 2010))
    • Merged by Mike Walsh FIN Wednesday, August 10, 2011 9:29 AM problem in one thread solved in the other thread
    Thursday, August 4, 2011 9:29 PM
  • Hi,

    You have all the the user information by default but it is hidden. You can see all the information in UserInformation page.

    Just go to Site Settings-->Site Permissions-->Settings-->List settings-->Click on your default view

    Now you can select the column from here whatever you want.

    Let us know if it is OK for you OR else you want to get all the information prgrammatically or somewhere else.


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
    Friday, August 5, 2011 6:08 AM
    Moderator
  • Thanks for replay, it help myself, i'd like put the better score, but i have another question, i notice that i should select one only field to show but i need show more that one field, por example email and department, Is it possible by configuration? or Do I need code feuture for it??, Do you have any code??, if the reply is not, don´t worry, i put hight score. Thanks a lot.
    Friday, August 5, 2011 3:10 PM
  • Hi humb3rt0x,

    From your description, is your user list a common list or others? Please provide more information about the list content type and column settings.

    As you said, ”I should select one only field to show but I need to show more than one field”, do you mean as Hemendra provided that in the user information list page? If so, you can select every column displayed in the view settings page.

    Thanks,

    Qiao Wei


    Monday, August 8, 2011 11:16 AM
    Moderator
  • hello, well, id tried this configuration Hemendra, but it should allow choose only one field , but i need three fields to the time, i making a feature for this, i have news for you when i go have results.
    Monday, August 8, 2011 7:40 PM
  • >but it should allow choose only one field , but i need three fields to the time

    You mean, you are able to select only one column? If yes then have you got any error when you select multiple columns while editing the default view?

    > i have news for you when i go have results.?

    > i making a feature for this

    Check this site if you are creating custom feature. It will help you

    http://www.zimmergren.net/archive/2008/06/25/sharepoints-hidden-user-list-user-information-list.aspx

     


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
    • Marked as answer by humb3rt0x Tuesday, August 9, 2011 9:11 PM
    Tuesday, August 9, 2011 12:49 PM
    Moderator
  • try using
    user[PropertyConstants.WorkEmail].Value 
    this will allow you to access the profiles WorkEmail it should also allow for autocomplete so you only get the correct items. 
    Tuesday, August 9, 2011 8:58 PM
  • Very very very thanks Hemendra, this site solve my problem, there is my code, for all body, is a feature:

    using

    System;

    using

    System.Collections.Generic;

    using

    System.Linq;

    using

    System.Text;

    using

    System.IO;

    using

    Microsoft.SharePoint;

    using

    Microsoft.Office.Server;

    using

    Microsoft.Office.Server.UserProfiles;

    using

    System.Web;

    using

    System.Web.UI;

    namespace

    FeatUsuarioPropiedades

    {

     

    public class ItemEventReceiver: SPItemEventReceiver

     

    {

     

    public override void ItemAdded(SPItemEventProperties properties){

     

    base.ItemAdded(properties);

     

    string[] IdUser;

     

    if (properties.ListTitle == "Comit de Categora")

    {

     

    SPListItem Item = properties.ListItem;

     

    IdUser =

    new string[2];

    IdUser = Item[

    "persona"].ToString().Split(';');

     

    #region

    buscando el usuario

     

    using (SPSite Site = new SPSite("http://pekaqpsrv622:2000/abastecimiento"))

    {

    IdUser[1] = IdUser[1].Replace(

    "#", "");

     

    SPWeb web = Site.OpenWeb();

     

    SPUser user = web.EnsureUser(IdUser[1]);

     

     

    try
     

    {

     

    SPListItem userItem = web.SiteUserInfoList.Items.GetItemById(user.ID);

     

    if (userItem["EMail"] == null)

    {

    Item[

    "Correo elctrnico"] = "";//pueda que esto no sea el nombre.
     

    }

     

    else
     

    {

    Item[

    "Correo elctrnico"] = userItem["EMail"];//pueda que esto no sea el nombre.

    }

     

    if (userItem["JobTitle"]==null)

    {

    Item[

    "Cargo2"] = "";

    }

     

    else

    {

    Item[

    "Cargo2"] = userItem["JobTitle"];

    }

     

    if (userItem["Department"] == null)

    {

    Item[

    "Departamento"] = "";

    }

     

    else

    {

    Item[

    "Departamento"] = userItem["Department"];

    }

    Item[

    "Mensaje"] = "Registrado OK";

    }

     

    catch (Exception ex)

    {

    Item[

    "Mensaje"] = "Error en Registro";

    }

    Item.Update();

    }

    #endregion

     

    }

    }

    }

    }

    • Marked as answer by humb3rt0x Tuesday, August 9, 2011 9:14 PM
    Tuesday, August 9, 2011 9:14 PM
    • Marked as answer by humb3rt0x Tuesday, August 9, 2011 9:17 PM
    Tuesday, August 9, 2011 9:17 PM