473,785 Members | 2,327 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing Credentials

Hi,
I am trying to retrieve XML created by ASP pages on different servers
and display them on a single ASP.Net page.

I was planning to use the XMLDocument and XMLResolver objects like
below:

xmlResolver.Cre dentials = CredentialCache .DefaultCredent ials
xmlDoc = New XmlDocument
xmlDoc.XmlResol ver = xmlResolver

Try
xmlDoc.Load(URL ) '
Catch ex As Exception
Throw ex
End Try
The URLs are secured using integrated windows authentication. When I
connect to the page I get the exception "The remote server returned an
error: (401) Unauthorized". But I can use the URL in IE and it
displays the XML properly.

Also if I change the line
xmlResolver.Cre dentials = CredentialCache .DefaultCredent ials
to
xmlResolver.Cre dentials = New NetworkCredenti al _
("myid", "mypassword ", "mydomain")
the code works without a problem.

I don't want to hard code the credentials in my code.
I am not sure if I am using the objects correctly.
If anybody knows what's wrong with the code or a better way to pass
through user credentials it would be greatly appreciated.
Nov 12 '05 #1
2 7522


Angelo Vargheese wrote:
Hi,
I am trying to retrieve XML created by ASP pages on different servers
and display them on a single ASP.Net page.

I was planning to use the XMLDocument and XMLResolver objects like
below:

xmlResolver.Cre dentials = CredentialCache .DefaultCredent ials
xmlDoc = New XmlDocument
xmlDoc.XmlResol ver = xmlResolver

Try
xmlDoc.Load(URL ) '
Catch ex As Exception
Throw ex
End Try
The URLs are secured using integrated windows authentication. When I
connect to the page I get the exception "The remote server returned an
error: (401) Unauthorized". But I can use the URL in IE and it
displays the XML properly.

Also if I change the line
xmlResolver.Cre dentials = CredentialCache .DefaultCredent ials
to
xmlResolver.Cre dentials = New NetworkCredenti al _
("myid", "mypassword ", "mydomain")
the code works without a problem.

I don't want to hard code the credentials in my code.
I am not sure if I am using the objects correctly.
If anybody knows what's wrong with the code or a better way to pass
through user credentials it would be greatly appreciated.


You can set up a Web.config file for your ASP.NET application and store
application specific data like the credentials there. That avoids
hardcoding the credentials in the code.

Here is an example file

<?xml version="1.0" encoding="UTF-8"?>
<configuratio n>
<appSettings>
<add key="god" value="Kibo" />
</appSettings>
</configuration>

You can add any data needed with further <add> elements.
Then inside your ASP.NET code you need to import SystemConfigura tion
and then you can read
ConfigurationSe ttings.AppSetti ngs["god"]
as in the following example

<%@ Page Language="C#" %>
<%@ Import Namespace="Syst em.Configuratio n" %>
<script runat="server">
void Page_Load () {
string appKey = ConfigurationSe ttings.AppSetti ngs["god"];
if (appKey != null) {
aLabel.InnerTex t = appKey;
}
}
</script>
<html>
<head>
<title>readin g application settings</title>
</head>
<body>
<p>
app key is
<span id="aLabel" runat="server"> </span>
</p>
</body>
</html>
The IIS server is not serving Web.config files to the browser.

You can find more about Web.config at
http://msdn.microsoft.com/library/en...figuration.asp
--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #2
Thanks for the reply Martin.

But I was hoping to use the Credentials of the user that was using the
ASP.Net page.

So if the user did not have authorization to the URL i would send back
the error "you are not authorized". The user would then only be able
to retrieve XML from servers they were authorized to.


Martin Honnen <Ma***********@ t-online.de> wrote in message news:<ub******* *******@TK2MSFT NGP10.phx.gbl>. ..
Angelo Vargheese wrote:
Hi,
I am trying to retrieve XML created by ASP pages on different servers
and display them on a single ASP.Net page.

I was planning to use the XMLDocument and XMLResolver objects like
below:

xmlResolver.Cre dentials = CredentialCache .DefaultCredent ials
xmlDoc = New XmlDocument
xmlDoc.XmlResol ver = xmlResolver

Try
xmlDoc.Load(URL ) '
Catch ex As Exception
Throw ex
End Try
The URLs are secured using integrated windows authentication. When I
connect to the page I get the exception "The remote server returned an
error: (401) Unauthorized". But I can use the URL in IE and it
displays the XML properly.

Also if I change the line
xmlResolver.Cre dentials = CredentialCache .DefaultCredent ials
to
xmlResolver.Cre dentials = New NetworkCredenti al _
("myid", "mypassword ", "mydomain")
the code works without a problem.

I don't want to hard code the credentials in my code.
I am not sure if I am using the objects correctly.
If anybody knows what's wrong with the code or a better way to pass
through user credentials it would be greatly appreciated.


You can set up a Web.config file for your ASP.NET application and store
application specific data like the credentials there. That avoids
hardcoding the credentials in the code.

Here is an example file

<?xml version="1.0" encoding="UTF-8"?>
<configuratio n>
<appSettings>
<add key="god" value="Kibo" />
</appSettings>
</configuration>

You can add any data needed with further <add> elements.
Then inside your ASP.NET code you need to import SystemConfigura tion
and then you can read
ConfigurationSe ttings.AppSetti ngs["god"]
as in the following example

<%@ Page Language="C#" %>
<%@ Import Namespace="Syst em.Configuratio n" %>
<script runat="server">
void Page_Load () {
string appKey = ConfigurationSe ttings.AppSetti ngs["god"];
if (appKey != null) {
aLabel.InnerTex t = appKey;
}
}
</script>
<html>
<head>
<title>readin g application settings</title>
</head>
<body>
<p>
app key is
<span id="aLabel" runat="server"> </span>
</p>
</body>
</html>
The IIS server is not serving Web.config files to the browser.

You can find more about Web.config at
http://msdn.microsoft.com/library/en...figuration.asp

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5828
by: Ole Hanson | last post by:
Hi I am trying to pass a credentials object to a webpage programmatically. I have a winApp (C#) that I want to be able to open a webpage (by starting IE), but the credentials required by IIS serving this webpage should be sent along automatically. This to prevent the user from being forced to login to the site. It should be something like LOGONUSER from the User32.dll native API, but just to a webpage...
3
2263
by: Das | last post by:
Hi all, I'm writig an application that sends an http request to java servlet file. I have to pass an xml file to the servlet. How should I pass xml file to the file. When I try to access the url directly it shows me Forbidden You do not have permission to access /RequestListenerServlet on this server.
7
4871
by: Steve Drake | last post by:
All, I am doing a WEBDAV request and I want to pass the users Credentials to the webdav server, eg some code like : Request.Credentials = CredentialCache.DefaultCredentials; This does not work, as I get AUTH FAIL, but if I pass the user name and password by using :
7
2619
by: Wade Wegner | last post by:
Hello, I have been desperately trying to programmatically authenticate a windows user, create their credentials, and then redirect them to a different server while passing the credentials at the same time so that they don't have to login again. Specifically, I have two webservers in the same domain. When I have a user go to Webserver A (which uses basic authentication) I programmatically create either a user credential or impersonate...
1
5259
by: jadher | last post by:
I try to access an asp page in a machine that has windows integrated authentication turned on. I use System.Net.Networkcredentials as well as System.Net.Webrequest and Webresponse. I receive a response but when I try to use Response.Redirect(), a popup windows appears asking me for user, password, domain. Is there a way to pass the credentials to the Reponse.Redirect function so I
4
2023
by: Dan Higman | last post by:
I'm sure this is easy and I'll be embarrassed when I see the answer, but I just can't figure this one out. Using .Net/ASP 1.1 on a server using integrated authentication-- I have a web page (.aspx) that will collect some data from the user, call a web service to get additional data, and then merge and format the data back to the user's browser. But I want the web service to authenticate with the user's credentials, not the credentials of...
3
4911
by: GRB | last post by:
My webiste has integrated windows authentication. I need to pass a clients credentials (username, password) to my site without the login pop up. I send the client to an anonymous page, get an encrypted cookie and read it to get the credentials. Then redirect the client to my web site. How can I pass the credentials to IIS and avoid the login pop up? Any help or related web sites is appreciated.
2
1585
by: Jay Balapa | last post by:
Hello, Win Forms app is able to connect to my webservice passing credentials as follows- myService.Credentials=System.Net.CredentialsCache.DefaultCredentials; Compact Framework does not have a CredentialsCache class. Is there an alternate way of passing default credentials?
4
1944
by: Kris Kennaway | last post by:
I want to make use of UNIX credential passing on a local domain socket to verify the identity of a user connecting to a privileged service. However it looks like the socket module doesn't implement sendmsg/recvmsg wrappers, and I can't find another module that does this either. Is there something I have missed? Kris
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10104
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.