views:

19

answers:

1

As you may know, MOSS 2007 offers functionality to synchronize Active Directory properties to SharePoint UserProfile Properties. You can map AD properties to userProfile properties in Shared Services > User Profile and Properties > View Profile properties (all the way at the bottom).

I'm currently investigating the possibility to synchronize modifications on userProfiles back to AD.

I'm new to SharePoint and struggling my way through its API's, but what I dug up so far, is that you can iterate to UserProfile changes and find out timestamps, old values, new values, etc.

    string siteUrl = @"http://[siteUrl]/";
    Microsoft.SharePoint.SPSite spsite = new Microsoft.SharePoint.SPSite(url);
    Microsoft.Office.Server.ServerContext serverContext = Microsoft.Office.Server.ServerContext.GetContext(spsite);
    Microsoft.Office.Server.UserProfiles.UserProfileManager userProfileMgr = new Microsoft.Office.Server.UserProfiles.UserProfileManager(serverContext);
    var collection = userProfileMgr.GetChanges();

    List<ProfilePropertyChange> changes = new List<ProfilePropertyChange>();
    foreach (Microsoft.Office.Server.UserProfiles.UserProfileChange change in collection)
    {
        if (change.ObjectType == Microsoft.Office.Server.UserProfiles.ObjectTypes.SingleValueProperty)
        {
            var singleValue = change as Microsoft.Office.Server.UserProfiles.UserProfileSingleValueChange;

        string oldValue = singleValue.OldValue;
        string newValue = singleValue.NewValue;
        var profileProperty = singleValue.ProfileProperty;
        DateTime modificationDate = singleValue.EventTime;

        ...

        }
    }

However, what I'm currently unable to discover, is programmatic access to the so called "Mapped Attribute" (the original property name in AD).

Can anybody point me to the SharePoint API that will reveale this information for me?

Many thanks

A: 

Steve Curran was kind enough to address my question on the MSDN forum:

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/019c1e60-babb-4942-90e1-d33e924c7c73

Using the PropertyMapCollection you may be able to look up the mapped AD attribute given the Userprofile name.

DataSource ds = upcm.GetDataSource(); PropertyMapCollection pmc = ds.PropertyMapping;

http://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.propertymapcollection%28office.12%29.aspx

DickB