?
Solved

How to force to check-in checked-out document in MOSS without taking ownership of it?

Posted on 2011-10-31
5
Medium Priority
?
1,207 Views
Last Modified: 2013-11-05
SharePoint experts,

I have a SharePoint user, who was working on a few checked-out documents in a MOSS document library, now that I, as an administrator of the site collection, need to force to check-in his checked-out documents during his absence WITHOUT taking these documents' ownership. Are there any ways I can do it either by UI or by scripting/programming? If yes, HOW?

Thanks a lot,
-Rick
0
Comment
Question by:RHADMIN
  • 3
  • 2
5 Comments
 
LVL 32

Expert Comment

by:Jamie McAllister MVP
ID: 37058645
0
 
LVL 32

Expert Comment

by:Jamie McAllister MVP
ID: 37058707
I know you're using MOSS, but Powershell should still work. If not, there are programming solutions. I can point you in the right direction, the syntax is straightforward.
0
 
LVL 1

Author Comment

by:RHADMIN
ID: 37058728
Thank you Jamie,

But the solutions I am looking for:
A solution can check-in these documents without changing these documents' original author name(without taking their ownership)

Will the powershell or programming solutions you're referring meet this requirement?

Thanks,
-Rick
0
 
LVL 32

Accepted Solution

by:
Jamie McAllister MVP earned 2000 total points
ID: 37058754
Put these things together and you're set.

Here is some code that allows impersonation in SharePoint:

http://blackninjasoftware.com/2009/04/09/how-to-programmatically-impersonate-users-in-sharepoint/

Use the users user token, which you'll be able to find from the SPUser object matching their userid.

Then see the code snippet below. It's something I wrote a while back. This actually does Publish, but you can easily change it to checkin instead. (I would but I'm writing in haste!)

This code can be put into a custom stsadm command, an admin only webpart etc.

You might be able to adapt the powershell script above to impersonate your user, but frankly I've not tried that. The black ninja software impersonation technique works great though.
SPList list = web.GetList(strUrl); 
foreach (SPListItem item in list.Items) 
{ SPFile sourceFile = item.File; 
if ((sourceFile.Level == SPFileLevel.Draft) && (sourceFile.CheckOutStatus == SPFile.SPCheckOutStatus.None)) 
{ sourceFile.Publish("File Automatically Bulk Published"); 

try { if (sourceFile.Item.ModerationInformation.Status == SPModerationStatusType.Pending) 
{ sourceFile.Approve("File Automatically Approved During Bulk Publish"); } } 
catch (System.Exception) 
{ //Suppress } 
sourceFile.Update(); } }

Open in new window

0
 
LVL 1

Author Comment

by:RHADMIN
ID: 37058804
Thank you Jamie,

I was as well thinking using impersonation as the only possibly solution for this, your input HELPS! I'd put it as admin webpart instead.

Enjoy,
-Rick
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
When installing SharePoint 2010 RTM I came across a strange error, I was getting timeouts during the installation. I searched the web and found the best solution to be found here (http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010genera…
Loops Section Overview
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month13 days, 12 hours left to enroll

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question