Domanda

I have a problem with regards to configuration on production environment. It turns out that user for User Profiles sync may not be given Replicate directory changes on root OU, which is needed for sync to work. Now, I need user profiles so the workflows can work. Is there a workaround here? I was thinking about some manual way of importing users, perhaps Powershell, saving data from AD into file and importing it again programmatically?

È stato utile?

Soluzione

Workaround is to implement some custom functionality that does the import. It can be PowerShell, Windows Service, pretty much anything that can query AD and can access SharePoint via SharePoint Server Object Model.

Note that you need to handle addition, updating, and possibly also removal scenarios, and figure out what User Profile Fields in SharePoint to override using AD values in case user has manually updated those in MySite.

E.g., create user profile in SharePoint using Server Object Model in case you would use Windows Service:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Server;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
using System.Web;
namespace UserProfilesSSOM
{
    class Program
    {
        static void Main(string[] args)
        {

            // Replace "domain\\username" and "servername" with actual values.
            string newAccountName = "domain\\username";
            using (SPSite site = new SPSite("http://servername"))
            {
                SPServiceContext serviceContext = SPServiceContext.GetContext(site);
                try
                {

                    // Create a user profile that uses the default user profile
                    // subtype.
                    UserProfileManager userProfileMgr = new UserProfileManager(serviceContext);
                    UserProfile userProfile = userProfileMgr.CreateUserProfile(newAccountName);

                    Console.WriteLine("A profile was created for " + userProfile.DisplayName);
                    Console.Read();
                }

                catch (System.Exception e)
                {
                    Console.WriteLine(e.GetType().ToString() + ": " + e.Message);
                    Console.Read();
                }
            }
        }
    }
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top