P
Parth
Hi,
I had written a piece of code for updating the task using impersonation and
code is as follows:
which has Derived class for the statusing :
StatusingDerived.SetImpersonationContext(isWindowsUser,userAccount,
myUserId, Guid.Empty, siteId, "1033");
then it goes to the set impersonation menthod:
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Services;
using System.Net;
using Microsoft.Office.Project.Server.Library;
using PSLibrary = Microsoft.Office.Project.Server.Library;
namespace WPSI
{
class StatusingDerived: Statusing
{
private static String contextString = String.Empty;
protected override WebRequest GetWebRequest(Uri uri)
{
//here we are overriding the GetWebRequest method and adding the
2 web request headers
WebRequest webRequest = base.GetWebRequest(uri);
if (contextString != String.Empty)
{
webRequest.UseDefaultCredentials = true;
//bool isImpersonating =
(System.Security.Principal.WindowsIdentity.GetCurrent(true) != null);
//isImpersonating = true;
webRequest.Credentials =
CredentialCache.DefaultNetworkCredentials;
webRequest.Headers.Add("PjAuth", contextString);
webRequest.Headers.Add("ForwardFrom",
"/_vti_bin/psi/statusing.asmx");
webRequest.PreAuthenticate = true;
}
return webRequest;
}
public static void SetImpersonationContext(bool isWindowsUser,
String userAccount,
Guid userGuid, Guid
trackingGuid, Guid pwaSiteId, String lcid)
{
contextString = GetImpersonationContext(isWindowsUser,
userAccount,
userGuid, trackingGuid, pwaSiteId, lcid);
}
private static String GetImpersonationContext(bool isWindowsUser,
String userAccount,
Guid userGuid, Guid trackingGuid, Guid pwaSiteId, String lcid)
{
PSLibrary.PSContextInfo contextInfo = new
PSLibrary.PSContextInfo(isWindowsUser, userAccount,
userGuid, trackingGuid, pwaSiteId, lcid);
String contextString =
PSLibrary.PSContextInfo.SerializeToString(contextInfo);
return contextString;
}
}
}
and then
Guid assn = new Guid("DB4E1B8C-0D55-4E61-98D2-AE3D1BCD7EF3");
Guid proj = new Guid("8612CF19-2C96-47EE-9939-B32823369CA9");
changexml = "<Changes>" +
"<Proj ID=\"" + proj+ "\">" +
"<Assn ID=\"" + assn + "\">" +
"<Change
PID=\"251658274\">5</Change>" +
"</Assn>" +
"</Proj>" +
"</Changes>";
staProxy.UpdateStatus(changexml);
staProxy.SubmitStatus(new Guid[] { assn }, "" +
"hiiiiii" + "");
Now I'm getting the Error saying that :
System.Web.Services.Protocols.SoapException: ProjectServerError(s)
LastError=GeneralSecurityAccessDenied Instructions: Pass this into
PSClientError constructor to access all error information
at
Microsoft.Office.Project.Server.WebService.Statusing.UpdateStatus(String
changexml)
Please some one tell me that where i am making mistakes...!!?
I had written a piece of code for updating the task using impersonation and
code is as follows:
which has Derived class for the statusing :
StatusingDerived.SetImpersonationContext(isWindowsUser,userAccount,
myUserId, Guid.Empty, siteId, "1033");
then it goes to the set impersonation menthod:
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Services;
using System.Net;
using Microsoft.Office.Project.Server.Library;
using PSLibrary = Microsoft.Office.Project.Server.Library;
namespace WPSI
{
class StatusingDerived: Statusing
{
private static String contextString = String.Empty;
protected override WebRequest GetWebRequest(Uri uri)
{
//here we are overriding the GetWebRequest method and adding the
2 web request headers
WebRequest webRequest = base.GetWebRequest(uri);
if (contextString != String.Empty)
{
webRequest.UseDefaultCredentials = true;
//bool isImpersonating =
(System.Security.Principal.WindowsIdentity.GetCurrent(true) != null);
//isImpersonating = true;
webRequest.Credentials =
CredentialCache.DefaultNetworkCredentials;
webRequest.Headers.Add("PjAuth", contextString);
webRequest.Headers.Add("ForwardFrom",
"/_vti_bin/psi/statusing.asmx");
webRequest.PreAuthenticate = true;
}
return webRequest;
}
public static void SetImpersonationContext(bool isWindowsUser,
String userAccount,
Guid userGuid, Guid
trackingGuid, Guid pwaSiteId, String lcid)
{
contextString = GetImpersonationContext(isWindowsUser,
userAccount,
userGuid, trackingGuid, pwaSiteId, lcid);
}
private static String GetImpersonationContext(bool isWindowsUser,
String userAccount,
Guid userGuid, Guid trackingGuid, Guid pwaSiteId, String lcid)
{
PSLibrary.PSContextInfo contextInfo = new
PSLibrary.PSContextInfo(isWindowsUser, userAccount,
userGuid, trackingGuid, pwaSiteId, lcid);
String contextString =
PSLibrary.PSContextInfo.SerializeToString(contextInfo);
return contextString;
}
}
}
and then
Guid assn = new Guid("DB4E1B8C-0D55-4E61-98D2-AE3D1BCD7EF3");
Guid proj = new Guid("8612CF19-2C96-47EE-9939-B32823369CA9");
changexml = "<Changes>" +
"<Proj ID=\"" + proj+ "\">" +
"<Assn ID=\"" + assn + "\">" +
"<Change
PID=\"251658274\">5</Change>" +
"</Assn>" +
"</Proj>" +
"</Changes>";
staProxy.UpdateStatus(changexml);
staProxy.SubmitStatus(new Guid[] { assn }, "" +
"hiiiiii" + "");
Now I'm getting the Error saying that :
System.Web.Services.Protocols.SoapException: ProjectServerError(s)
LastError=GeneralSecurityAccessDenied Instructions: Pass this into
PSClientError constructor to access all error information
at
Microsoft.Office.Project.Server.WebService.Statusing.UpdateStatus(String
changexml)
Please some one tell me that where i am making mistakes...!!?