Integrated Authentication Problem

Integrated Authentication Problem


I have an e-space that has inside a webflow. The webflow has the Integrated Authentication property = Yes. This e-space references an extension. In that extension i have methods to access via WEBDAV an exchange server and i need to pass the credencial of the logged user that is running the OS application in my HttpWebRequest. I didn't found a way do to this straigth forward. I managed do to this using impersonation but this generates a problem. I need to put in the web.config the line to authorize the impersonating (which will be replace each time i compile the e-space) and disable the anounymous authentication in the IIS (which doesn't allow me to compile). Can anyone help me solving this issue?

Thanks in Advance,
Ruben Silva

Yes, setting Integrated Authentication to Yes should do the trick. You don't need to change the web.config file manually.

In your extension you can use System.Threading.Thread.CurrentPrincipal.Identity.Name.

This will return the domain\username that accessed the page using windows authentication.

Hope this helps,
Tiago Simões
I managed to get the current principal by:

OutSystems.HubEdition.RuntimePlatform.AppInfo ainfo = OutSystems.HubEdition.RuntimePlatform.AppInfo.GetAppInfo();

But i have tried using your tip but the credentials that i passed to the HttpWebRequest aren't the correct ones.

How can i create/get the user credentials to passed to the HttpWebRequest?
Here is how you can do impersonation programmatically and pass the credentials to the other request:

System.Security.Principal.WindowsImpersonationContext impersonationContext;
impersonationContext = ((System.Security.Principal.WindowsIdentity)
string url = "http://server/yoururl.aspx";
WebRequest r = HttpWebRequest.Create(url);
CredentialCache cache =new CredentialCache();
//Create the credentials
NetworkCredential credential = (NetworkCredential) CredentialCache.DefaultCredentials;
cache.Add(new Uri(url), "Negotiate", credential);
r.Credentials = cache;
//Execute the request r.GetResponse();

Get back to me if you need any more help.

Tiago Simoes