views:

139

answers:

1

Here's the situation, i want to have a user that can enter time on behalf of other (programmaticaly).

When i do QueueUpdateTimeSheet a web service of ms project server, it doesn't work if a try to enter time for an other.

I try the impersonification but i need to know the username and password of the person that i want to impersonate. I could have those information but i don't want to manage it.

I start to look at surrogate timesheet. I don't know if this will be the respond to my problem.

Can anybody help me ...

+2  A: 

There's no magic method that lets you surrogate timesheet as far as I know. If you want to be able to use QueueUpdateTimesheet's method on behalf of other users, you'll have to "hack" a bit your DataSet.

Be aware that you need to do the prerequisite to impersonate the user (http://msdn.microsoft.com/en-us/library/aa974413.aspx). Once its all done you can proceed ;)

First of all, retreive your timesheetRow:

Proxy.TimesheetListDataSet.TimesheetsRow tsFound = null;
            foreach (Proxy.TimesheetListDataSet.TimesheetsRow ts in ds.Timesheets)
            {
                if (ts.WPRD_START_DATE <= day.Date && ts.WPRD_FINISH_DATE > day.Date)
                {
                    tsFound = ts;
                    break;
                }
            }

Then retrieve the timesheet dataSet:

Proxy.TimesheetDataSet tds = timesheetSvc.ReadTimesheet(tsFound.TS_UID);

Then perform this to enable surrogating:

if (Boolean.Parse(tds.Headers.Rows[0]["TS_IS_CONTROLLED_BY_OWNER"].ToString()) == true)
                {
                    tds.Headers.Rows[0]["TS_IS_CONTROLLED_BY_OWNER"] = false;
                    tds.Headers.Rows[0]["TS_CREATOR_RES_UID"] = "[SUPER USER GUID]"
                }

Finally push the updated dataSet:

timesheetSvc.QueueUpdateTimesheet(Guid.NewGuid(), tsFound.TS_UID, updatedTimesheetDataSet);

Hope it helps!

Farewell

Luji