Sunday, September 1, 2013

Adding values ​​to the people search results in SharePoint Farm

שלום חברים,
היום אני רוצה לשתף אתכם ביכולת נחמדה שקיימת ב-SharePoint , שינוי דף תוצאות חיפוש.
את השינוי עשיתי בדף תוצאות החיפוש של אנשים. בדף זה מוצגים מס' ערכים על המשתמש וניתן להוסיף ערכים נוספים כגון : מנהל ישיר, יום הולדת, מספר טלפון נייד/בית ועוד.
אז איך עושים את זה ? ראו והשכילו :)    :
1.       ראשית יש לוודא שהפרופילים מאונדקסים (במידה ולא יש ליצור מקור תוכן מסוג SharePoint ולאנדקס )









2.       יש להוסיף Role ע"מ להגיע לאינדוקס מיטבי.



3.       אני יוצא מתוך נק' הנחה שקיים לכם בחווה Search Center ומכאן שקיים Scope  ברירת מחדל של חיפוש אנשים.
a.       בצעו חיפוש של משתמש בארגון ובדקו אילו ערכים חוזרים.


b.       ערכו את דף תוצאות החיפוש וערכו את ה-WebPart של תוצאות החיפוש.


c.       ניתן לראות את התוצאות שחוזרות בפורמט XML , ע"מ לראות אילו ערכים ניתן להוסיף (הערכים שניתן להוסיף הינם ערכים מנוהלים בלבד – Manage Properties) ע"י הוספת קטע הקוד הבא בחלון של XSL Editor (לאחר שלחצתם על הכפתור, שימרו את קטע הקוד ה-Defaultי של ה-XSL בצד).

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xmp><xsl:copy-of select="*"/></xmp>
</xsl:template>
</xsl:stylesheet>




d.       שמרו את השינויים ושמרו את הדף.
e.       רעננו את הדף וראו את התוצאות בפורמט XML.


4.       חזרו על צעד 3 עד לסעיף c , הוסיפו את הערכים המנוהלים לשורת Text 'Fetched Properties' (אני הוספתי Cell Phone   ו- Home Phone, חשוב שאלו יהיו ערכים מנוהלים, במידה ולא הוסיפו את הערכים המנוהלים ומפו אותם לערכים שמאונדקסים, Crawl Properties).


5.       הוסיפו את הערכים לקוד XSL ע"מ שתוכלו לראות את הנתונים בדף תוצאות חיפוש.






6.       שמרו את השינויים , שמרו את הדף.
7.       בצעו חיפוש נוסף. (חשוב לוודא שהערכים שהוספתם מאונדקסים ומסונכרנים לפרופיל)
התוצאה, נתונים נוספים על היישות המבוקשת.





בהצלחה !
רון נס.

============================================================================================================================================================================================================================================================




Hello Friends ,
Today I want to share a nice ability that exists in SharePoint , changing the search results page .
I did change of the people search results page. This page are Display values for the user and can add additional values such as direct manager , birthday , phone number, Mobile / Home and more.
So how do you do it? See and learn :
1.     First, ensure that the Profiles are indexed ( if not then create a SharePoint content source and index the content Source)






2.      Role must be added in order to reach the optimal indexing .


3.     I'm out of points off your existing Search Center farm and hence there is a default Scope People Search .
a. Perform a search on some user in the organization and see what return values .


b . Edit the search results page and edited the WebPart 's search results.


c . If You want to see the results are repeated in XML format , in order to see which values can be added ( values are values that you can add only managed - Manage Properties) You can achieve it by adding the following snippet of XSL Editor window ( after you've pressed the button , save the code in the - Default J. of the XSL side) .

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xmp><xsl:copy-of select="*"/></xmp>
</xsl:template>
</xsl:stylesheet>



d . Save the changes and save the page.
e . Refresh the page and see the results in XML format .


4.      Repeat step 3 to Section C , add the values managed line Text 'Fetched Properties' ( I added Cell Phone and Home Phone , it is important that these values be managed , if not add the values managed and shampoos them indexed values , Crawl Properties) .

5.      Add the XSL code values in order that you can see the database search page .




6.      Save the changes , save the page.
7.      Perform another search . ( It is important to ensure that the values you added indexed and synchronized profile )
The result , additional data requested entity .




Good luck :)
Ron Ness .


Synchronize User profile pictures in SharePoint


שלום חברים,
היום ביצעתי סנכרון תמונות משתמש לרכיב הפרופילים בחוות SharePoint של הארגון. הסנכרון התבצע בכמה שלבים :
1.       בחירת מקור התוכן ממנו SharePoint ייבא את התמונה.
a.       אני בחרתי לייבא את התמונה מה-Active Directory .
b.       ב-AD היה נתיב לתמונה ששמורה בכונן רשת.
c.       העתקת התמונות לשרת SP
                                                               i.      העתקתי את התמונות תחת הנתיב הבא :
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\EmployeePictures

                                                             ii.      הבחירה נעשתה בגלל הסיבה שתיקיית ה-Layouts ממופה ב-IIS וניתן לגשת אל התוכן שבה דרך הדפדפן, כאשר נרשום בדפדפן :
נוכל לראות את התמונה בדפדפן. (במידה וחשקה נפשך בתיקייה אחרת/נתיב אחר יש לוודא שיש מיפוי לנתיב Relative בIIS תחת ה-Site  הרלוונטי)

2.       יצירת Profile Property חדש שנקרא PictureStr שמקבל את הערך ה-Stringי של נתיב התמונה.





a.       בשלב היצירה יש לבחור את הערך מה-AD שייובא לתוך SP.


3.       ביצוע סנכרון מול AD.
4.       השדה Picture בפרופיל ב-SP הינו מ-Type URL , לכן מה שנדרשתי לעשות הוא להמיר את הנתיב שסונכרן  ל-URL, עשיתי זאת ע"י כתיבת Script ב-PowerShell שמשרשר את כתובת ה-SiteCollection עם שם הקובץ (תמונת המשתמש ע"י מזה חד-חד-ערכי של מס' עובד).


5.       עדכון השדה Picture בפרופיל עם ערך URL שמציג את תמונת המשתמש.

להלן ה-Script :
[void][reflection.assembly]::Loadwithpartialname("Microsoft.Office.Server") | out-null
$site=new-object Microsoft.SharePoint.SPSite("http://ServerName:Port") #Central Admin site
$servercontext=[Microsoft.Office.Server.ServerContext]::GetContext($site)
$site.Dispose() # clean up
$upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($servercontext)

$pc = $upm.GetEnumerator()
$counter = 0
$counter2 = 0

foreach($p in $pc)
{
 
  if(($p["PictureStr"].Value) -eq $null)
  {
    Write-Host "No Picture for $($p["AccountName"].Value)" -foregroundcolor Red
    $counter++
  }
           
  else
  {
    # $p["PictureUrl"].Value
    # $p["PictureStr"].Value

    $StringPic = $p["PictureStr"].ToString()
    Write-Host $StringPic -foregroundcolor Cyan
    $pArr = $StringPic.trim("\\Picture's Path")
    Write-Host $pArr -foregroundcolor Cyan


    if($StringPic -eq "\\Picture's Path")
    {
      Write-Host "$($StringPic)" -foregroundcolor Yellow
      Write-Host "No Picture for $($p["AccountName"].Value)" -foregroundcolor Yellow
      $picURL = $null
    }
    else
    {    
      $picURL = "http://ServerName:port/SiteCollection/_layouts/PaisEmployeePictures/$pArr"  # Change the ServerName:Port and the SiteCollection, Example :" http://SharePointPortal/_layouts/PaisEmployeePictures/$pArr"
    }


    if(($p["PictureUrl"].Value) -eq $null)
     {
      $p["PictureUrl"].Value = $picURL
      $p.Commit()
      Write-Host $p["PictureUrl"].Value -foregroundcolor Magenta
      Write-Host "The PictureURL Attribute for $($p["AccountName"].Value) Updated " -foregroundcolor Green
     }
    
    $counter2++
  }
 
}

Write-Host "The Number of Users that doesn't have Picture is : " $counter -foregroundcolor Yellow
Write-Host "The Number of Users that has Picture is : " $counter2 -foregroundcolor Cyan




והרי התוצאה לפניכם :


בהצלחה !
רון נס.




  




============================================================================================================================================================================================================================================================













Hello Friends,
Today I've sync  photos to Profiles Component on SharePoint farm.
 Synchronization occurs in several stages:
1.     Choosing a the content source to Import  images for SharePoint.
a. I chose to import the picture from Active Directory.
b. In AD the Images was stored some Attribute that his value was the path of the image on a network drive.
c. Copy images to the SharePoint server
i. I copied the pictures under the following path:
C: \ Program Files \ Common Files \ Microsoft Shared \ Web Server Extensions \ 14 \ TEMPLATE \ LAYOUTS \ EmployeePictures

ii. The choice was made because of the reason the Layouts folder mapped in IIS and can be accessed through the browser which content when we write in the browser:
http://ServerName:Port/SiteCollection/_layouts/EmployeePictures/ID.JPG
We can see the image in the browser.
(If you like fancy another folder / path then make sure that Relative path mapping in IIS under the relevant Site)

2.     Create a new Profile Property called 'PictureStr' that equals the String the path of the image. (String Property )






a. At work there is to choose the value what-AD will be imported into the SP.



3.     Synchronizing with AD.
4.     The 'Picture'  field in Profile Component is  an URL Type, so what I was required to do is convert the path has been synchronized to 'PictureStr'  to Legal URL, I did this by writing a PowerShell  script in concatenate the address SiteCollection with the file name (the image by than one - one - the values ​​of a number of works).


5.     Update Picture field with a URL that displays the value of the image.

The following script:

[void][reflection.assembly]::Loadwithpartialname("Microsoft.Office.Server") | out-null
$site=new-object Microsoft.SharePoint.SPSite("http://ServerName:Port") #Central Admin site
$servercontext=[Microsoft.Office.Server.ServerContext]::GetContext($site)
$site.Dispose() # clean up
$upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($servercontext)

$pc = $upm.GetEnumerator()
$counter = 0
$counter2 = 0

foreach($p in $pc)
{
 
  if(($p["PictureStr"].Value) -eq $null)
  {
    Write-Host "No Picture for $($p["AccountName"].Value)" -foregroundcolor Red
    $counter++
  }
           
  else
  {
    # $p["PictureUrl"].Value
    # $p["PictureStr"].Value

    $StringPic = $p["PictureStr"].ToString()
    Write-Host $StringPic -foregroundcolor Cyan
    $pArr = $StringPic.trim("\\Picture's Path")
    Write-Host $pArr -foregroundcolor Cyan


    if($StringPic -eq "\\Picture's Path")
    {
      Write-Host "$($StringPic)" -foregroundcolor Yellow
      Write-Host "No Picture for $($p["AccountName"].Value)" -foregroundcolor Yellow
      $picURL = $null
    }
    else
    {    
      $picURL = "http://ServerName:port/SiteCollection/_layouts/PaisEmployeePictures/$pArr"  # Change the ServerName:Port and the SiteCollection, Example :" http://SharePointPortal/_layouts/PaisEmployeePictures/$pArr"
    }


    if(($p["PictureUrl"].Value) -eq $null)
     {
      $p["PictureUrl"].Value = $picURL
      $p.Commit()
      Write-Host $p["PictureUrl"].Value -foregroundcolor Magenta
      Write-Host "The PictureURL Attribute for $($p["AccountName"].Value) Updated " -foregroundcolor Green
     }
    
    $counter2++
  }
 
}

Write-Host "The Number of Users that doesn't have Picture is : " $counter -foregroundcolor Yellow
Write-Host "The Number of Users that has Picture is : " $counter2 -foregroundcolor Cyan



And the result before you:





Good Luck :)
Ron Ness.