0

A few days back, it has come to my attention that a specific site was again modified in SharePoint 2010. A week before i had fixed it so people could use again a webpart. Today i saw it was again gone.

I'm working to update all the security to prevent such changes, but some people have difficulties with the fact they will loose the rights. But we are working on that.

In this case, there are unfortunatly still a few people who are able to make modifications on the specific site.

I have thought about creating a small site to display administrative information. I know where i can see creation time, last modified date, but not who created it or who modified it.

Is there some property or a way to see who makes the changes on a page and who created it?

for Example i want to see on the root site that is is created on 01-01-2010 by MyDomain\MyAccount

After that i will do the same for lists, libraries, security.

2 Answers 2

0

You need to use SPFile object like below:

SPFile homePageFile=web.GetFile("/SitePages/Home.aspx");

Then use 4 properties of homePageFile.TimeCreated, homePageFile.Author, homePageFile.TimeLastModified, homePageFile.ModifiedBy to show who and when the file was created and modified.

Now for your application, for the web itself you can use web.Files[0] which is typically "default.aspx" file. For the lists, you can use:

SPList myList=web.Lists["list"];
SPFile listFile=myList.Files[0];

listFile will typically be "AllItems.aspx" which is the default view file. Use properties above to retrieve Author and Editor Users and Dates. Good luck.

3
  • Thank you both for the quick reply. i have seen in all site content that i can find the pages. This is good in most cases. We have also something like mysharepoint.intranet/sites/PictureUploader/default.aspx I cannot find this in the all site content part. Is this then accessible by code you provided? If this is also accessible, then I can make a webpart that read the data and represent it in a table. Thanks for your support.
    – JoeriDC
    Aug 13, 2013 at 13:20
  • If "mysharepoint.intranet/sites/PictureUploader" is a subsite, then yes; It is accessible through the code I suggested. Just give the complete url to GetFile(string url) method to retrieve it. If "mysharepoint.intranet/sites/PictureUploader" is actually another site collection, then you need to use GetFile(string url) method on another SPWeb object. You can retrieve it by: SPSite mySite=new SPSite("mysharepoint.intranet/sites/PictureUploader"); SPWeb myWeb=mySite.OpenWeb(); myWeb.GetFile("default.aspx"); Aug 13, 2013 at 13:49
  • This works perfectly. thank you! Small example taken from your reply how i tested: SPSite mySite = new SPSite(txtUrl.Text); SPWeb myWeb = mySite.OpenWeb(); SPFile file = myWeb.GetFile("default.aspx"); SPUser usr = file.ModifiedBy; lblDetails.Text = usr.Name;
    – JoeriDC
    Aug 13, 2013 at 14:09
0

Assuming your page is located in either the pages or the sitepages library then check in the library. In either case, looking at the properties of the page will show who last made changes and when.

Modified = when Modified By = who

If you turn on version control on your library then you can also see the history of changes and even restore a previous version if needed

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.