If you tried to post a screenshot, unfortunately it won't come through
in the NG. You can email it to me if you'd like.
I modified this code to work from my laptop (which is a member of a
domain) to my Dev VPC (which is a member of its own workgroup). if the
VPC and I were in the same domain and I had proper permissions, it would
work as defined in the SDK. Also, if I were running the impersonation
code from the Project Server WFE/App Server as the SSP Admin or another
account with proper permissions, it would work as defined in the SDK.
Here's the sample code that works for me:
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
WebRequest _webRequest = base.GetWebRequest(uri);
if (_contextString != String.Empty)
{
_webRequest.UseDefaultCredentials = false;
bool isImpersonating =
(System.Security.Principal.WindowsIdentity.GetCurrent(true) != null);
_webRequest.Credentials = new NetworkCredential("admin",
"password", "epmdev");
_webRequest.Headers.Add("PjAuth", _contextString);
_webRequest.Headers.Add("ForwardedFrom",
"/_vti_bin/psi/Resource.asmx");
_webRequest.PreAuthenticate = true;
}
return _webRequest;
}
Just as a side note. instead of embedding the credentials in this
property, I would set create a NetworkCredential static field in the
ResourceDerived class and add two methods to get and set it. then, I
would change the code to this:
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
WebRequest _webRequest = base.GetWebRequest(uri);
if (_contextString != String.Empty)
{
bool isImpersonating =
(System.Security.Principal.WindowsIdentity.GetCurrent(true) != null);
if (_credentials != null)
{
_webRequest.UseDefaultCredentials = false;
_webRequest.Credentials = _credentials;
}
else
{
_webRequest.UseDefaultCredentials = true;
_webRequest.Credentials =
CredentialCache.DefaultCredentials;
}
_webRequest.Headers.Add("PjAuth", _contextString);
_webRequest.Headers.Add("ForwardedFrom",
"/_vti_bin/psi/Resource.asmx");
_webRequest.PreAuthenticate = true;
}
return _webRequest;
}
Hope it works for you too!
--
Stephen Sanderlin
Principal Consultant
MSProjectExperts
For Project Server Consulting:
http://www.msprojectexperts.com
For Project Server Training:
http://www.projectservertraining.com
Read my blog at:
http://www.projectserverhelp.com/
Join the community at:
http://forums.epmfaq.com
<
Stephen
I'm not quite there but I think we're getting somewhere. I'm using the
unchanged ResourceDerviced.cs file from the SDK which contains the
following override:
protected override WebRequest GetWebRequest(Uri uri)
{
WebRequest webRequest = base.GetWebRequest(uri);
if (contextString != String.Empty)
{
webRequest.UseDefaultCredentials = true;
bool isImpersonating =
(System.Security.Principal.WindowsIdentity.GetCurrent(true) != null);
webRequest.Credentials =
CredentialCache.DefaultCredentials;
webRequest.Headers.Add("PjAuth", contextString);
webRequest.Headers.Add("ForwardedFrom",
"/_vti_bin/psi/resource.asmx");
webRequest.PreAuthenticate = true;
}
return webRequest;
}
If I use that as is, and set
resProxyBySSP.Credentials = new NetworkCredential("login", "password",
"machinename");
in Program.cs, then I get a 401 error.
If I remove
webRequest.UseDefaultCredentials = true;
webRequest.Credentials = CredeitnalsCache.DefaultCredentials;
then I get a 404 error instead.
The uri I'm making the request to is
http://chappzh56:56737/SharedServices1/PSI/Resource.asmx and I can make
a GET on that uri just fine from a webbrowser.
Looking at things in Wireshark I see that my authentication seems to be
accepted now when I send the header, the server responds with 100
Continue, I send the actual request body (which contains the following):
<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema"><soap:Body><GetCurrentUserUid
<
http://www.w3.org/2001/XMLSchema>
xmlns="
http://schemas.microsoft.com/office/project/server/webservices/Resource/"
/></soap:Body></soap:Envelope>
And then the project server responds with 404. If I send the same
request to the PWA url, I get the desired result.
I went into the event log and noted that the server is trying to tell me
that the PWA site GUID is incorrect... the documentation isn't quite
clear on that.
I have a bunch of DBs on that server.. aspnetdb for forms
authentication, 4 ProjectServer_* DBs for Project Server,
SharePoint_AdminContent__guid, SharePoint_Config, SharedServices1_DB,
WSS_Content_PSS (the content DB for the PSS so I figured this is the DB
where I have to take the guid from.. ) and WSS_Content_PWA (the pwa
content DB).. upon looking at the Webs table in WSS_Content_PWA I
actually found a site with FullURL PWA which is the url of PWA, so I
tried that SiteId, and now I get a 401 again.If I use the SiteId from
the other entry in that DB (sites/ProjectServer.. the sharepoint default
part for my Project Server), I get another 404 with again an entry in
the event log telling me that the SiteId I'm giving was not found in the
ProjectSiteCollection for this SSP.
So I'm a bit stumped here.. if I send the wrong GUID, authentication
works but then I cannot proceed. If I send the proper GUID,
authentication fails.
So I'm wondering.. you wouldn't happen to have a modified version of the
sample that actually works so that I could try it?.
Regards
Stephan
P.S. Another weird effect:
"Stephen Sanderlin" <stephen NS-DOT sanderlin A-NS-T msprojectexperts
DOT-NS com> wrote in message
I just realized that I had the password for my VPC saved hence why it
always just works for me. I did this because I was trying to simulate
actually being part of the same domain as the machine.
Ive cleared this saved password and I am able to reproduce your issue
when leaving webRequest.Credentials set to
CredentialsCache.DefaultCredentials. The call is successful if I set it
to new NetworkCredential(username, password, domain). The request
fails if I set it to new NetworkCredential(domain\username,
password).
So, try setting webRequestCredentials to new
NetworkCredential(username, password, machinename) instead of new
NetworkCredential(machinename\username, password).
Sorry about that it came to me shortly after I wrote my last post.
Please let me know if this resolves your issue!
--
Stephen Sanderlin
Principal Consultant
MSProjectExperts
For Project Server Consulting:
http://www.msprojectexperts.com
For Project Server Training:
http://www.projectservertraining.com
Read my blog at:
http://www.projectserverhelp.com/
Join the community at:
http://forums.epmfaq.com