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 (); } } } |