Moss user profile (3): view the modification history of the user configuration file

Source: Internet
Author: User

Moss user profile (3): view the modification history of the user configuration file

The previous section introduced how to obtain and modify the user configuration file. In the Shared Service Management Center, I did not find a place to view the modification history of the specified user configuration file, I only read in the reference book and read how to use the object model to view previous modification records.

In the Code experiment, only the attribute fields to be added are displayed, but the modification to the field value is not recorded in it. It seems that this operation can only be recorded for adding, deleting, and other operations, modification to attribute field values cannot be recorded.

The following code is posted from reference books.

Using system;

Using system. Collections. Generic;

Using system. text;

Using Microsoft. SharePoint;

Using system. Web;

Using Microsoft. Office. server;

Using Microsoft. Office. server. administration;

Using Microsoft. Office. server. userprofiles;

 

Namespace consoleapplication4

{

Class Program

{

Static void main (string [] ARGs)

{

Try

{

Using (spsite site = new spsite ("http: // mossweb: 1111/sites/publish "))

{

Servercontext context = servercontext. getcontext (SITE );

Userprofilemanager profilemanager = new userprofilemanager (context );

// Obtain the changes within two days

Datetime startdate = datetime. utcnow. Subtract (timespan. fromdays (2 ));

Userprofilechangequery changequery = new userprofilechangequery (false, true );

Userprofilechangetoken changetoken = new userprofilechangetoken (startdate );

Changequery. changetokenstart = changetoken;

Changequery. Anniversary = true;

Changequery. singlevalueproperty = true;

Changequery. multivalueproperty = true;

Changequery. distributionlistmembership = true;

Changequery. sitemembership = true;

USERPROFILE user1 = profilemanager. getuserprofile (@ "eoffice \ user1 ");

Userprofilechangecollection changes = user1.getchanges (changequery );

Foreach (userprofilechange change in changes)

{

Console. writeline (change. eventtime. tostring ());

If (change is userprofilepropertyvaluechange)

{

Userprofilepropertyvaluechange propertychange = (userprofilepropertyvaluechange) change;

Console. writeline ("Property {0}-{1}", propertychange. profileproperty. Name, propertychange. changetype. tostring ());

}

Else if (change is userprofilemembershipchange)

{

Userprofilemembershipchange membershipchange = (userprofilemembershipchange) change;

Console. writeline ("membership {0}-{1}", membershipchange. membergroup. displayname, membershipchange. changetype. tostring ());

}

}

}

}

Catch (exception ex)

{

Console. writeline (ex. Message );

}

Console. Readline ();

}

}

}

The Code comes from references.
Reference: SAMs Microsoft SharePoint 2007 Development unleashed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.