Saturday, March 24, 2012

Windows Authentication with WebDav

Hey folks,

I'm trying to communicate with our Exchange server using WebDav to get the
User's personal contacts folder. Works fine if I hardcode their username
and password (obviously not an acceptable solution), but when I use
Integrated Authentication I get "(401) Unauthorized".

I've got <identity impersonate="true" /> and I've got <authentication
mode="Windows" />, and I've set up IIS to use Windows Authentication. I
know this works, because I can log into our SQL Server using it.

How do I use the logged in user's credentials to work with WebDav?

The following works fine:
MSXML2.ServerXMLHTTP30 oXmlHttp = new MSXML2.ServerXMLHTTP30();
oXmlHttp.open("PROPFIND", "http://theUrl", false, "Domain\\user",
"password");

This following two produces the error though:
1:
HttpWebRequest Request = WebRequest.Create("http://theUrl") as
HttpWebRequest;
Request.Credentials = CredentialCache.DefaultCredentials;

2:
Principal.WindowsIdentity currWinID =
(Principal.WindowsIdentity)User.Identity;
Principal.WindowsImpersonationContext ic = currWinID.Impersonate();
HttpWebRequest Request = WebRequest.Create("http://theUrl") as
HttpWebRequest;
Request.Credentials = CredentialCache.DefaultCredentials;John i think you might have to Hardcode it..
I think its not just passing your Atuthentication as you said if you have
imperosnated the user and still doesn't work
What i guess is it can't pass your credentials to the next hop its should be
something with delegation i think it won't do it if you are using
NTLM but with kerberos it should work
Try posting your problem to the security GROUP
Patrick

"John Smith" <m@.ty.com> wrote in message
news:OrWh3EVuFHA.460@.TK2MSFTNGP15.phx.gbl...
> Hey folks,
> I'm trying to communicate with our Exchange server using WebDav to get the
> User's personal contacts folder. Works fine if I hardcode their username
> and password (obviously not an acceptable solution), but when I use
> Integrated Authentication I get "(401) Unauthorized".
> I've got <identity impersonate="true" /> and I've got <authentication
> mode="Windows" />, and I've set up IIS to use Windows Authentication. I
> know this works, because I can log into our SQL Server using it.
> How do I use the logged in user's credentials to work with WebDav?
>
> The following works fine:
> MSXML2.ServerXMLHTTP30 oXmlHttp = new MSXML2.ServerXMLHTTP30();
> oXmlHttp.open("PROPFIND", "http://theUrl", false, "Domain\\user",
> "password");
> This following two produces the error though:
> 1:
> HttpWebRequest Request = WebRequest.Create("http://theUrl") as
> HttpWebRequest;
> Request.Credentials = CredentialCache.DefaultCredentials;
> 2:
> Principal.WindowsIdentity currWinID =
> (Principal.WindowsIdentity)User.Identity;
> Principal.WindowsImpersonationContext ic = currWinID.Impersonate();
> HttpWebRequest Request = WebRequest.Create("http://theUrl") as
> HttpWebRequest;
> Request.Credentials = CredentialCache.DefaultCredentials;
John,
I have a similar problem. I am using client on workstation running IE6
that login to ASP.NEt web server using Windows Authentication with
impersonation. The server ASP.NET page uses WebDav to access Exchange
Server 2003. THe WebDav request failes with "The remote server returned
an error: (401) Unauthorized".
If the client is running IE browser on the Web Server , WebDav queries
are succeded.
I've changed Web Server to "trust this computer to delegate", but the
error is the same.

Have you solved your problem?
Regards,
Michael Freidgeim

--
mfreidge
----------------------
mfreidge's Profile: http://www.highdots.com/forums/m792
View this thread: http://www.highdots.com/forums/t2923752
I solved my problem. See my post "'To run WebDav queries against
Exchange Folders from ASP.NET -use Kerberos . '
(http://geekswithblogs.net/mnf/archive/2005/09/27/55089.aspx)"

--
mfreidge
----------------------
mfreidge's Profile: http://www.highdots.com/forums/m792
View this thread: http://www.highdots.com/forums/t2923752
I solved my problem. See my post "'To run WebDav queries against
Exchange Folders from ASP.NET -use Kerberos . '
(http://geekswithblogs.net/mnf/archive/2005/09/27/55089.aspx)"

--
mfreidge
----------------------
mfreidge's Profile: http://www.highdots.com/forums/m792
View this thread: http://www.highdots.com/forums/t2923752

0 comments:

Post a Comment