J
John Smith
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;
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;