Solved

PictureURL

Posted on 2011-09-13
10
419 Views
Last Modified: 2012-05-12
Having 3 webapps:  WebApp1 (CountryA)  + WebApp2 (CountryB) - and a "common" Mysite

I would like that human resource dept. in each country maintain they "own" pictures of the employes by a picture library on each countrys site...

Right now both CountryA and CountryB and the Mysite looks in the picturelibrary that resides on CountryA

I have done by this powershell script:

#My Site URL
$mySiteUrl = "http://mysite/"
 
#The part of the picture URL you are trying to find
$pictureLibUrl = "http://countryA/employesspictures"

#The internal name for PictureURL
$upPictureURLAttribute = "PictureURL"
#The internal name for Login
$LoginAttribute = "AccountName"

 
#Get site objects and connect to User Profile Manager service
$site = Get-SPSite $mySiteUrl
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$profiles = $profileManager.GetEnumerator()
 
foreach ($userProfile in $profiles) {

  $userLogin = $userProfile[$LoginAttribute].Value.Split('\')[1]
  $newPictureURL = $pictureLibUrl + $userLogin + ".jpg"
  $userProfile[$upPictureURLAttribute].Value = $newPictureURL
  $userProfile.Commit()

  write-host "User: " $userLogin " Picture: " $newPictureURL
} 

Open in new window


How can I accomplish that the common "Mysite" should look in both CountryA and CountryB and that CountryA should look in http://countryA/employepictures AND CountryB should look in http://countryB/employepictures  ??


Hope it makes sense....  
0
Comment
Question by:Aarsleff
  • 5
  • 3
  • 2
10 Comments
 
LVL 16

Expert Comment

by:quihong
ID: 36533488
You can't have it "look in both". You need to add some logic based on another profile field (i.e. office location), and then set the pictureURL field.
0
 

Author Comment

by:Aarsleff
ID: 36533938
Ok...do you have and powershell example (I'm not a programmer)

Btw... The CountryA and CountryB are in different OU's in AD - but both gets imported by the UPS application in SP    

It's to achieved that the Users in CountryA don't have access to CountryB and vice versa.... of course they all have access to the mysite webapp
0
 
LVL 38

Accepted Solution

by:
Justin Smith earned 500 total points
ID: 36535583
I've never seen this done, not even sure it's possible out of the box.  I'm anxious to see if there will be a solution to this.

Can't the HR people just upload photos directly to the Photo Library on the MySite host site?
0
 

Author Comment

by:Aarsleff
ID: 36536178
Oh..yes... that could be a solution ...will the employees pictures then be displayed on each country webapp if one search for a person within the countryA...?? (the people search has to function as a phonebook.. )
0
 
LVL 38

Expert Comment

by:Justin Smith
ID: 36536329
As long as both web apps are subscribed to the User Profile App, yes.
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:Aarsleff
ID: 36536440
They are ... so that's the solution then... thanks...  ;)

So I'll just change the script to?:

#My Site URL
$mySiteUrl = "http://mysite/"
 
#The part of the picture URL you are trying to find
$pictureLibUrl = "[b]http://Mysite/employeespictures[/b]"

#The internal name for PictureURL
$upPictureURLAttribute = "PictureURL"
#The internal name for Login
$LoginAttribute = "AccountName"

Open in new window

0
 
LVL 16

Expert Comment

by:quihong
ID: 36538004
I am a little confused on the ultimate goal here.

It sounds like you're okay now to use one photo library for all your employee photos regardless of country. This would be the simplest route. Just make sure that everyone has read access to the library so the photo is correctly displayed in the people search result. Your HR department would have Contributor rights to upload photos.

I would suggest you check if the photo exist before setting it. See code.
foreach ($profile in $upm)
{
   $photoUrl = $portalurl + "/employee photos/" + $profile["EmployeeID"].Value + ".jpg"
   $photoFile = $portalweb.GetFile($photoUrl)

   if($photoFile.Exists) {
      $profile["PictureURL"].Value = $portalurl + "/employee photos/" + $profile["EmployeeID"].Value + ".jpg"
      $profile.Commit()
   }
   else {
      $profile["PictureURL"].Value = $null
      $profile.Commit()
   } 
}

Open in new window

0
 

Author Comment

by:Aarsleff
ID: 36538473
The goal are to keep it simple... By that there's no problem for both HR departments (or more countries later) to have access to the http://mysite/employeepictures with the role and All authentificated users to have read access...;)


I move the picture lib to mysite root and just replace the foreach code block with yours and Run the script?
0
 
LVL 16

Expert Comment

by:quihong
ID: 36539409
Pretty much. Please test in a non-production env.

You would probably want to schedule the script.
0
 

Author Comment

by:Aarsleff
ID: 36540649
Thanks ... :D

Am I wrong when i say that the variables in your "fore each" block differs from my original script...? (I am a total NooB to code and syntax..)

You have:

$photoUrl = $portalurl + "/employee photos/" + $profile["EmployeeID"].Value + ".jpg"
   $photoFile = $portalweb.GetFile($photoUrl)

if($photoFile.Exists) {
$profile["PictureURL"].Value = $portalurl + "/photos/" + $profile["EmployeeID"].Value + ".jpg"
$profile.Commit()
}

Open in new window


Could you please adjust it to the complete script code ?

#My Site URL
$mySiteUrl = "http://mysite/"

#The part of the picture URL you are trying to find
$pictureLibUrl = "http://countryA/employesspictures"

#The internal name for PictureURL
$upPictureURLAttribute = "PictureURL"
#The internal name for Login
$LoginAttribute = "AccountName"


#Get site objects and connect to User Profile Manager service
$site = Get-SPSite $mySiteUrl
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$profiles = $profileManager.GetEnumerator()

<!--foreach ($userProfile in $profiles) {

$userLogin = $userProfile[$LoginAttribute].Value.Split('\')[1]
$newPictureURL = $pictureLibUrl + $userLogin + ".jpg"
$userProfile[$upPictureURLAttribute].Value = $newPictureURL
$userProfile.Commit()-->


foreach ($profile in $upm)
{
$photoUrl = $portalurl + "/employee photos/" + $profile["EmployeeID"].Value + ".jpg"
$photoFile = $portalweb.GetFile($photoUrl)

if($photoFile.Exists) {
$profile["PictureURL"].Value = $portalurl + "/photos/" + $profile["EmployeeID"].Value + ".jpg"
$profile.Commit()
}
else {
$profile["PictureURL"].Value = $null
$profile.Commit()
}
}

write-host "User: " $userLogin " Picture: " $newPictureURL
}

Open in new window


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Scenario: Let’s say you have a quote worksheet in Excel that you use to work up sales figures and such for your clients. You utilize SharePoint to manage and keep track of these documents. You would like values from your worksheet to populate Sh…
I recently came across an issue with a MOSS 2007 deployment where access into some sub-sites were denied, even for the MOSS farm administrators. A bit of background to the setup of this MOSS farm; this was a three server setup, consisting of a fr…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now