Hola:
Que tal, la verdad hay algo que no entiendo muy bien.
Resulta que estoy necesitando realizar una llamada al PDS desde una
aplicacion ASP.NET, desarrolada con VS.NET 2005.
Ahora bien realice el codigo y lo probe desde una aplicacion WinForm y
funciona perfecto, pero desde la aplicacion asp.net me da un problema
de autenticacion.
The remote server returned an error: (401) Unauthorized.
Inverstigando un poco encontre este link:
http://msdn.microsoft.com/library/d...ations.asp
El cual segun veo el problema es que la llamada desde la aplicacion
asp.net, no esta pasando las crecenciales, y segun este link debo hacer
uso de kerberos, pero deberia haber alguna forma ams facil.
El documento esta muy bueno, les paso el codigo que estoy usando para
lograr la utenticacin contra Project Server 2003:
using System.Net;
using System.Xml;
internal bool LogonProjectServer()
{
string sURL = Config.Instance().ProjectHelper_LogonURL +
"?un=" + Config.Instance().ProjectHelper_Usuario + "&pwd=" +
Config.Instance().ProjectHelper_Password;
HttpWebRequest httpRequest (HttpWebRequest)WebRequest.Create(sURL);
HttpWebResponse httpResponse = null;
CookieContainer conCookie = new CookieContainer();
httpRequest.CookieContainer = conCookie;
httpRequest.Credentials = CredentialCache.DefaultCredentials;
try //Return the response.
{
httpResponse = (HttpWebResponse)httpRequest.GetResponse();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(httpResponse.GetResponseStream());
sCookie = GetLogonStatus(xmlDoc);
if(sCookie.Length < 10)
{
throw new Exception("Project Server logon
failed.Logon Status = "
+ sCookie);
sCookie = "";
return false;
}
return true;
}
catch(WebException ex)
{
throw new Exception(ex.Message);
return false;
}
finally
{
// Close the response to free resources.
if (httpResponse != null)
httpResponse.Close();
}
}
private string GetLogonStatus(XmlDocument XMLDoc)
{
XmlNode Root;
string Result;
Result = "";
Root = XMLDoc.DocumentElement;
if (Root.LastChild.Name == "Cookie")
{
Result = Root.LastChild.InnerText;
}
else
{
Result = Root.FirstChild.InnerText;
}
return (Result);
}
La url que estoy usando es:
http://<servidor>/projectserver/LgnPsAu.asp
El error me lo da en la linea:
httpResponse = (HttpWebResponse)httpRequest.GetResponse();
Si alguien realizo una llamada (o mejor dicho la autenticacion) a PDS
del Project 2003, y pudo pasar esto, si es tan amable, me podrias
indicar como realizarlo, estaria agradecido.
Saludos
Leer las respuestas