Configure User Profile sync connections
-
Monday, January 24, 2011 4:21 PM
So, I've worked through all the PS scripting to set up the user profile sync service (include the sql ownership issues).
Now I'd like to move to the configuring of connections. As I understand it, I need to get to the UserProfileConfigManager. I have two code sets I try -
function GetUserProfileConfigManager1([string]$PortalURL) { $site= new-object Microsoft.SharePoint.SPSite($PortalURL) $servicecontext=[Microsoft.SharePoint.SPServiceContext]::GetContext($site) $upcm = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($servicecontext) $site.Dispose() # clean up $upcm } function GetUserProfileConfigManager2([string]$PortalURL) { $site= new-object Microsoft.SharePoint.SPSite($PortalURL) $servercontext=[Microsoft.Office.Server.ServerContext]::GetContext($site) $upcm = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($servercontext) $site.Dispose() # clean up $upcm }
The 1st uses the new way, the second uses the old (deprecated) way. Both give this error on the 'new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager' call:
New-Object : Exception calling ".ctor" with "1" argument(s): "Object reference not set to an instance of an object."
In both cases, the returned object is not null.
I did notice, however, in the 1st case, that $servicecontext returns
PS Y:\MyModules\SpSetup> $servicecontext SiteSubscriptionId ------------------ 00000000-0000-0000-0000-000000000000
I can see how this could be considered 'not set to an instance'.
I've got 2010 with Dec 2010 cum. My url is pointing to my claims site (over FBA). I've never run a profile import.
What is the right way to do this? Or what else do I have to do to make this work?
GregM
All Replies
-
Wednesday, February 23, 2011 9:47 PMHas anyone done this?
GregM -
Tuesday, March 08, 2011 9:10 AM
I'm trying something similar.
$site = Get-SPSite $url
if ($site)
{Write-Host "Successfully obtained site reference!"}
else
{Write-Host "Failed to obtain site reference"}$serviceContext = Get-SPServiceContext($site)
if ($serviceContext)
{Write-Host "Successfully obtained service context!"}
else
{Write-Host "Failed to obtain service context"}
$upManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($serviceContext)if ($upManager)
{Write-Host "Successfully obtained user profile manager!"}
else
{Write-Host "Failed to obtain user profile manager"}
$synchConnection = $upManager.ConnectionManager[$connectionName]if ($synchConnection)
{Write-Host "Successfully obtained synchronization connection!"}
else
{Write-Host "Failed to obtain user synchronization connection!"}Write-Host "Adding the attribute mapping..."
$synchConnection.PropertyMapping.AddNewMapping([Microsoft.Office.Server.UserProfiles.ProfileType]::User, $spsProperty, $fimProperty)
Write-Host "Done!"BUT I'm getting the same error as you and my SiteSubscriptionId is also returning the below.
SiteSubscriptionId
------------------
00000000-0000-0000-0000-000000000000Did you ever manage to sort this out?
Also want to confirm, are you pointing your $PortalURL to you Central Admin site?
-
Tuesday, March 08, 2011 12:47 PMNo, and according to a reply I got from Spencer Harbar (http://www.harbar.net/), there is no current way to use cmdlets to do what we want.
GregM -
Tuesday, March 08, 2011 8:21 PMYes, I was pointing at CA.
GregM -
Wednesday, March 09, 2011 11:23 AM
I had the same exception when running the exact same code as GetUserProfileConfigManager1.
The issue is that the powershell script is running under an account that has no rights on the user propfile service application. I added it to "Permissions" with "Full Control" and it was ok.
- Proposed As Answer by ClaraOscura Wednesday, March 09, 2011 11:23 AM
- Marked As Answer by Greg McCarty-w Wednesday, March 09, 2011 12:56 PM
-
Wednesday, March 09, 2011 12:56 PM
Ding, ding, ding, ding! Points for you! You are a genius!
I was running as my setup account. When I ran as my farm account, it worked.
Spent 5 minutes looking for the connection info (no luck), so if you have a suggestion, let me know.
Thanks!!!
GregM -
Tuesday, May 03, 2011 2:11 PM
Ok, to get the connection info, the setup account must have permissions to the User Profile Application in two places.
1) As a administrator with full control
2) connection permissions as full control
Then you have access to the connection manager and can programatically access the connections.
GregM- Proposed As Answer by Frank-Ove Thursday, December 20, 2012 11:32 AM
-
Monday, May 16, 2011 6:38 PM
FYI - Got the powershell script running that creates a connection. Of course, the import fails. Why?
Because when you go through CA, the code does a lot of work mapping the attributes found in the LDAP server to the attributes in SP.
So, it can be done. It's just going to take a lot more time.
GregM -
Tuesday, January 24, 2012 9:10 PMI was experiencing the same issue in my script that upload profile pictures in bulk. When I logged in as the farm account, (instead of my user account which has all the rights and more of the farm account), the script worked.
-
Friday, May 04, 2012 4:38 AM
At the beginning, I'm confused, but look everywhere, and at last got the things done.
To make it more clear, go to Central Administration > Application Management > Manage service applications.
Click the row (not the link) of your User Profile service application, click Permissions on the ribbon. Add your account here, only 1 permission level, Full Control so its must be easier for you to add.
Thanks, anyway! Really helped me!
"Jangan bertanya seberapa besar mimpi yang akan kau raih, tetapi bertanyalah seberapa besar dirimu untuk mimpi itu"
http://otak-otak-it.blogspot.com
- Edited by Radityo Ardi Hernowo Friday, May 04, 2012 4:41 AM

