Showing posts with label SharePoint Administration. Show all posts
Showing posts with label SharePoint Administration. Show all posts

Saturday, 29 November 2014

Exporting UPA profile connection mappings from SharePoint

The below script allows you to export all the profile properties used in the User Profile Service along with any mapping used for a particular Profile Sync connection.

Replace the bits in yellow with your own variables:

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Get the site context
$siteUrl = "<<Site Url>>"
$site = Get-SPSite $siteUrl
$context = Get-SPServiceContext $site


#Retrieve a list of all property mappings
function Get-Mappings ($context)
{
    $upam = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context)
    $cm = $upam.ConnectionManager["<<Name of your UPA sync connection>>"]
    $maps = $cm.PropertyMapping.GetEnumerator()
   
    $maps | ForEach-Object{
      $returnValue = @{
        "Column" = $_.ProfileProperty.Name
        "Mapping" = $_.DataSourcePropertyName
      }
     
      New-Object PSObject -Property $returnValue | Select ("Column", "Mapping")
    }
}

#Create a new UserProfileConfigManager object
$upam = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context)

#Get the core properties
$coreProps = $upam.ProfilePropertyManager.GetCoreProperties()


#Match the core properties to their coresponding mappings
function Get-CorePropsMapping ($coreProps, $maps)
{
    foreach ($coreProp in $coreProps)
    {
        $map = $maps | Where-Object {$_.Column -eq $coreProp.Name}
     
        $value = @{
            "Column" = $coreProp.DisplayName
            "Mapping" = $map.Mapping
        }
     
       New-Object PSObject -Property  $value | Select ("Column", "Mapping")
    }
}

#Call the get mappings function
$maps = Get-Mappings -context $context

#Call the CorePropsMapping function and output to a gridview
Get-CorePropsMapping $coreProps $maps | Out-GridView

This can be used if you should need to recreate the mapping or UPA service (...say if the User Profile Sync service is stuck starting.. for instance)

Thursday, 17 January 2013

Extending a web application to allow anonymous access

Perform the following steps
  1. In Central Administration under Application Management go to “Manage web applications”.
  2. Next select the Web application you wish to extend.
  3. In the ribbon Web Applications > under Contribute click “Extend”
  4. In the resulting pop-up choose Create new IIS Website and change the Port number and Host header to suit
  5. Select NTLM as the Authentication provider and Allow anonymous (to yes), choose SSL as appropriate
  6. Under the zone select Internet
  7. Clicking ok will extended the web application to a new application pool. This may take a while.
  8. Next head to the site through the new port number and you will notice you are still authenticated (i.e. not anonymous). Go to All site settings and “Site permissions”.
  9. In the ribbon a new button will be visible with the title “Anonymous access”. Click that and select either:
    • Entire Site - will give View items across the entire site for anonymous users 
    • Lists and libraries – will allow anonymous users access to the lists and libraries which they are granted access to directly or indirectly (lists with permissions inheriting from parent). You can allow anonymous users permissions to update a list but not a document library, to do this navigate to the list and select permissions. Again select “Anonymous access” and select the rights they should have on the list.