how do you set a cookie for axshdocvw

J

John

I am using forms authentication in our reporting service. After
authenticating, I get a cookie back and want to set that cookie in the
axshdocvw browser control to view the report so the user doesn't have
to log in again. How can I do this? I tried sending the session id as
a parameter in the render command but it looks like it only applies to
link together multiple render calls.

Thanks John
 
T

Teo Lachev

John,

I assume you are talking about WinForm app. If yes, you may find my sample
useful. The idea is to store the cookie and pass it explicitly with each
call to Render().

http://prologika.com/blog/archive/2004/08/27/169.aspx

--
Hope this helps.

-----------------------------------------------------
Teo Lachev, MCSD, MCT
Author: "Microsoft Reporting Services in Action"
Publisher website: http://www.manning.com/lachev
Buy it from Amazon.com: http://shrinkster.com/eq
Home page and blog: http://www.prologika.com/
 
J

John

Teo, thanks for your reponse. I did use the proxy class in your sample
to get the cookie, however I am not using render() call to render the
report. I am using the url and calling navigate in the axshdocvw
browser control. I don't think the browser control would use the proxy
class when sending web requests.
I tried adding the cookie as a part of the header in navigate call but
that didn't seem to work. The reporting service seemed to get the
cookie but I still got redirected to the forms authentication page.

Any help would be appreciated,
thanks John
 
G

Guest

John,

And why are you intiating the LogonUser call in your WinForm instead of
letting axshdocvw do the job just like you would do it in the browser?

1. axshdocvw request the report.
2. RS redirects to the login page which calls LogonUser.
3. RS sends the cookie to axshdocvw
4. axshdocvw caches it and sends it back happily with each subsequent request.

Am I missing something here?
 
J

John

The winform does the initial login in order to display a list of
reports available and allows some user input of parameters which are
common to all reports. I specify the url for the report selected along
with the parameters.
When the report is displayed in the control, the user can fill in any
report specific parameters and render the report.

Another somewhat unrelated question. I was using integrated login to
the database but when I used the custom form login, it tries to login
as the Windows network user. How do I set the user?

John
 
J

John

The application was based on the rs explorer sample. If forms
authentication is used, what needs to be done with the rs explorer
sample to get it working?

John
 
T

Teo Lachev

I see. In this case you just need to figure out a way to pass the
sqlAuthCookie to the WebBrowser control. I don't have much time to test this
but it looks like the Navigate method of the control has headers argument
which you can use to pass the cookie header.

What I would do is use tcpTrace to see what the cookie looks like. It should
be something like <the path to the report> (URL encoded) <cookie value>.
Then, I would try to create this header and pass it to the control. Perhaps,
there is a better way but you can use this a start.


--
Hope this helps.

-----------------------------------------------------
Teo Lachev, MCSD, MCT
Author: "Microsoft Reporting Services in Action"
Publisher website: http://www.manning.com/lachev
Buy it from Amazon.com: http://shrinkster.com/eq
Home page and blog: http://www.prologika.com/
-----------------------------------------------------
 
J

John

I tried to put the cookie string in the header parameter of navigate.
The tcptrace tool shows that the cookie part of the header is being
filtered out before it reaches the report server. I tried playing
around with security zones and overriding the cookie handling for the
web site but couldn't get it to work.
It looks like I'll move the logon and report listing to the web
control and write something separate to set the common report
parameters.

If anyone gets rs explorer to work with forms authentication, please
post the solution.

John
 
M

Mike

Did you find a way to do this? I am trying to do the same thing (set a
cookie on the navigate header) but it seems to get deleted by the
server. Another header item I put in makes it does make it through. I
set the cookie in the standard format of

Cookie: <name>=<value>;<name>=<value>

so I have

string sCookies = "MyCookie=MyCookieValue";

object o = null;
object oHeader = "Cookie: " + sCookies + "\r\nMyItem: YES\r\n";

browser.Navigate(sURL, ref o, ref o, ref o, ref m_oHeader);

Now I've seen that the server does get the header item

MyItem: YES

but the cookie I sent is not in the cookies that the server receives.
I'm really lost here...

Mike
 
T

Teo Lachev

John,

So, this thread really boils down to how to manually set a cookie in the
WebBrowser control. I did some research on your behalf but couldn't find a
definite answer. Some things you can try:

http://support.microsoft.com/defaul...port/kb/articles/Q172/9/98.ASP&NoWebContent=1

http://groups.google.com/groups?hl=...-8&selm=OUM94uiEBHA.500%40tkmsftngp07&rnum=19

The BeforeNavigate event instead of Navigate
http://groups.google.com/groups?hl=...2u5oh%24chj%241%40nyheter.chalmers.se&rnum=33

If this doens't help post a question to the
microsoft.public.inetsdk.programming.webbrowser_ctl. There must be a way :)
--
Hope this helps.

-----------------------------------------------------
Teo Lachev, MCSD, MCT
Author: "Microsoft Reporting Services in Action"
Publisher website: http://www.manning.com/lachev
Buy it from Amazon.com: http://shrinkster.com/eq
Home page and blog: http://www.prologika.com/
-----------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top