Windows forms controls in IE + Web Services

A

Adam Bieganski

Hi,

I have a windows forms control hosted in a WebForm (.aspx) like this:

<object id="myCtl" classid="UC1.dll#UC1.UC1" width="500" height="400"
VIEWASTEXT></object>

Now, the control inside calls some Web Service's method, which returns some
data, like this:
WS1.BWebService ws = new WS1.BWebService();
ws.Credentials = System.Net.CredentialCache.DefaultCredentials;
ws.GetData();

Everything works fine, as long as both the WebForm and the Web Service
are in IIS's applications which have anonymous access turned on.

Nevertheless, I would like the Web Service to be accessed basing on the
Windows Integrated Authentication.
Unfortunately, when I switch the Web Service's IIS application access to
Windows Integrated, the windows forms control is not displayed in the
WebForm (instead an icon is displayed showing something like "url not found"
or sth).
I also switched the security mode of the IIS application the WebForm
resides in to Windows Authentication, and put this code on the WebForm to be
sure the Windows Authentication works:

<% Response.Write(Session.SessionID + "|" + User.Identity.Name + ":" +
User.Identity.IsAuthenticated); %>

which actually does display the session ID, the right user and "true"
(standing for "yes, the uses has been authenticated").

Now, I expected the windows forms control to obtain the user name and
password from the WebForm it is hosted in, and then use it against the Web
Service it calls. Well - it doesn't.
When I host the control in a windows form, then everything works fine.

My question is then:
- How to make the windows forms control hosted in an ASP.NET WebForm to use
the WebForm's credentials to call Web Services?

Thanks in advance for any help,
 
A

Adam Bieganski

WS1.BWebService ws = new WS1.BWebService();
ws.Credentials = System.Net.CredentialCache.DefaultCredentials;
ws.GetData();
(...)
Now, I expected the windows forms control to obtain the user name and
password from the WebForm it is hosted in, and then use it against the Web
Service it calls. Well - it doesn't.

ok, already figured it out:
the line:

ws.Credentials = System.Net.CredentialCache.DefaultCredentials;

requires a permission to access the System.Environment variable, and I had
my whole http://localhost in "Trusted Sites", not "Local Intranet" (which is
default).
And my "Trusted_Zone" was configured in .NET Configuration to have only
"Internet permission set", which doesn't contain the permission to access
System.Net.CredentialCache.DefaultCredentials.

Now it works fine.
Maybe the above will help somebody.

Regards,
 

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