T
Thomas Mueller-Lynch
I want to use impersonation within a second thread of an httpwebrequest.
While configuring IIS with basic authentication everything works fine.
Changing to Intergrated Windows Authentication the thread (which should return a secure web-page) returns the http status code 401.
My web.config looks like:
.....
<identity impersonate="true"/><authentication mode="Windows" />
.....
My Testpage looks like:
dim url as String = "https://server/secure/index.html"
dim Req as HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
Req.Method = "GET"
Req.ContentType = "application/x-www-form-urlencoded;charset=iso-8859-1"
Req.PreAuthenticate = true
if Request.ServerVariables("AUTH_TYPE") = "Basic"
Req.Credentials = new System.Net.NetworkCredential(Request.ServerVariables("AUTH_USER"),Request.ServerVariables("AUTH_PASSWORD"))
else
Req.Credentials = CredentialCache.DefaultCredentials
' Should impersonate the user in case of NTLM, shouldn't it???
end if
dim Resp as HttpWebResponse = DirectCast(req.GetResponse(),HttpWebResponse)
dim Reader as StreamReader
Reader = new StreamReader(Resp.GetResponseStream())
while Reader.Peek() > -1
strLine = Reader.ReadLine()
Trace.write(strLine)
end while
Reader.Close()
Resp.Close()
The included thread should impersonate the logged-on user (NTLM or Basic).
What did I do wrong?
Thomas
While configuring IIS with basic authentication everything works fine.
Changing to Intergrated Windows Authentication the thread (which should return a secure web-page) returns the http status code 401.
My web.config looks like:
.....
<identity impersonate="true"/><authentication mode="Windows" />
.....
My Testpage looks like:
dim url as String = "https://server/secure/index.html"
dim Req as HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
Req.Method = "GET"
Req.ContentType = "application/x-www-form-urlencoded;charset=iso-8859-1"
Req.PreAuthenticate = true
if Request.ServerVariables("AUTH_TYPE") = "Basic"
Req.Credentials = new System.Net.NetworkCredential(Request.ServerVariables("AUTH_USER"),Request.ServerVariables("AUTH_PASSWORD"))
else
Req.Credentials = CredentialCache.DefaultCredentials
' Should impersonate the user in case of NTLM, shouldn't it???
end if
dim Resp as HttpWebResponse = DirectCast(req.GetResponse(),HttpWebResponse)
dim Reader as StreamReader
Reader = new StreamReader(Resp.GetResponseStream())
while Reader.Peek() > -1
strLine = Reader.ReadLine()
Trace.write(strLine)
end while
Reader.Close()
Resp.Close()
The included thread should impersonate the logged-on user (NTLM or Basic).
What did I do wrong?
Thomas