PDS desde aplicacion ASP.NET

28/06/2006 - 15:43 por Leandro Tuttini | Informe spam
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

Preguntas similare

Leer las respuestas

#1 Leandro Tuttini
30/06/2006 - 14:29 | Informe spam
Me auto respondo.
Encontre la solucion para poder autenticarme en el PDS de project desde
asp.net.

Simplemente debia configurar en el web.config la impersonalizacion, o
sea simplemente tenia que agrear el tag:

<identity impersonate="true" userName="domain\username"
password="userspassword" />


Configurando correctamente esto funciono perfecto.

Saludos
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida