473,320 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Authentication, Remoting, and Database Access problem

I am trying to setup a solution that will include a client which will access
a database via remoting calls. I am hosting my remoting project in IIS, and
am using Windows Integrated security. Since some of my users will be coming
in through the web (from non-trusted domains) to log into their local domain
account, I am trying to implement a login screen which will gather the user
data (login, pwd, domain). The login screen will be displayed only if the
user's default credentials do not authenticate. I have setup a small test
project to work out the kinks in the process, with the remoting part having
2 methods:
GetMessage() - Returns a string that includes the
HttpContext.Current.User.Identity.Name but has no
database access
GetMostExpensiveProducts - Creates a connection to the NorthWind
database and executes the
[Ten Most Expensive] stored procedure

I have found that if I allow the default credentials to go through, both
calls work correctly. However, when I create a set of credentials from the
login screen, the GetMessage shows the proper username (in domain\username
form) but the GetMostExpensiveProducts call errors with the following error
message:
Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

The GetMostExpensiveProducts has the following connection string:
"Provider=SQLOLEDB;Data Source=Dev2k;Initial Catalog=Northwind;
Integrated Security=SSPI;Trusted_Connection=yes"

The code on the client to create and set the credentials looks like this:
Dim _NWInfo As iNWInfo
Dim serverCredentials As New NetworkCredential
Dim channelproperties As IDictionary
Dim serverURL As String =
"http://localhost/dotNET/RemotingTest/NWInfo.rem"

...

_NWInfo =
CType(Activator.GetObject(GetType(RemotingInterfac e.iNWInfo), serverURL),
RemotingInterface.iNWInfo)

channelproperties =
ChannelServices.GetChannelSinkProperties(_NWInfo)
'Comment out the next line to cause 401 error and force manual login
to happen
'channelproperties("credentials") =
CredentialCache.DefaultCredential

Try
txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMessage
Catch ex As System.Net.WebException When ex.Message.indexof("401") >
0
Dim loginDlg As New Login
loginDlg.ShowDialog()
If loginDlg.DialogResult = Windows.Forms.DialogResult.OK Then
serverCredentials.UserName = loginDlg.txtUserName.Text
serverCredentials.Password = loginDlg.txtPassword.Text
serverCredentials.Domain = loginDlg.txtDomain.Text
loginDlg.Close()
End If
channelproperties("credentials") = serverCredentials

txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMessage
Catch ex As System.Net.WebException When ex.Message.IndexOf("could
not be resolved") > 0
txtResults.Text += vbCrLf & "I couldn't find the server you
specified: " & serverURL
Catch ex As Exception
txtResults.Text = txtResults.Text & vbCrLf & ex.Message & vbCrLf
& ex.Source & vbCrLf & _
GetType(Exception).ToString
End Try
txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMessage

Can anyone tell me what I am doing wrong here?

TIA
Ron L

Nov 23 '05 #1
2 3107
I think I found the problem. I had the <identity impersonate="true">
directive in the system.runtime.remoting | application | Channels section of
my Web.Config. When I copied it the System.Web section, my connection
started to work.

Ron L

"Ron L" <ro**@bogus.Address.com> wrote in message
news:u$**************@TK2MSFTNGP10.phx.gbl...
I am trying to setup a solution that will include a client which will
access a database via remoting calls. I am hosting my remoting project in
IIS, and am using Windows Integrated security. Since some of my users will
be coming in through the web (from non-trusted domains) to log into their
local domain account, I am trying to implement a login screen which will
gather the user data (login, pwd, domain). The login screen will be
displayed only if the user's default credentials do not authenticate. I
have setup a small test project to work out the kinks in the process, with
the remoting part having 2 methods:
GetMessage() - Returns a string that includes the
HttpContext.Current.User.Identity.Name but has no
database access
GetMostExpensiveProducts - Creates a connection to the NorthWind
database and executes the
[Ten Most Expensive] stored procedure

I have found that if I allow the default credentials to go through, both
calls work correctly. However, when I create a set of credentials from
the login screen, the GetMessage shows the proper username (in
domain\username form) but the GetMostExpensiveProducts call errors with
the following error message:
Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

The GetMostExpensiveProducts has the following connection string:
"Provider=SQLOLEDB;Data Source=Dev2k;Initial Catalog=Northwind;
Integrated Security=SSPI;Trusted_Connection=yes"

The code on the client to create and set the credentials looks like this:
Dim _NWInfo As iNWInfo
Dim serverCredentials As New NetworkCredential
Dim channelproperties As IDictionary
Dim serverURL As String =
"http://localhost/dotNET/RemotingTest/NWInfo.rem"

...

_NWInfo =
CType(Activator.GetObject(GetType(RemotingInterfac e.iNWInfo), serverURL),
RemotingInterface.iNWInfo)

channelproperties =
ChannelServices.GetChannelSinkProperties(_NWInfo)
'Comment out the next line to cause 401 error and force manual
login to happen
'channelproperties("credentials") =
CredentialCache.DefaultCredential

Try
txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMessage
Catch ex As System.Net.WebException When ex.Message.indexof("401")
> 0

Dim loginDlg As New Login
loginDlg.ShowDialog()
If loginDlg.DialogResult = Windows.Forms.DialogResult.OK Then
serverCredentials.UserName = loginDlg.txtUserName.Text
serverCredentials.Password = loginDlg.txtPassword.Text
serverCredentials.Domain = loginDlg.txtDomain.Text
loginDlg.Close()
End If
channelproperties("credentials") = serverCredentials

txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMessage
Catch ex As System.Net.WebException When ex.Message.IndexOf("could
not be resolved") > 0
txtResults.Text += vbCrLf & "I couldn't find the server you
specified: " & serverURL
Catch ex As Exception
txtResults.Text = txtResults.Text & vbCrLf & ex.Message &
vbCrLf & ex.Source & vbCrLf & _
GetType(Exception).ToString
End Try
txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMessage

Can anyone tell me what I am doing wrong here?

TIA
Ron L

Nov 23 '05 #2
I think I found the problem. I had the <identity impersonate="true">
directive in the system.runtime.remoting | application | Channels section of
my Web.Config. When I copied it the System.Web section, my connection
started to work.

Ron L

"Ron L" <ro**@bogus.Address.com> wrote in message
news:u$**************@TK2MSFTNGP10.phx.gbl...
I am trying to setup a solution that will include a client which will
access a database via remoting calls. I am hosting my remoting project in
IIS, and am using Windows Integrated security. Since some of my users will
be coming in through the web (from non-trusted domains) to log into their
local domain account, I am trying to implement a login screen which will
gather the user data (login, pwd, domain). The login screen will be
displayed only if the user's default credentials do not authenticate. I
have setup a small test project to work out the kinks in the process, with
the remoting part having 2 methods:
GetMessage() - Returns a string that includes the
HttpContext.Current.User.Identity.Name but has no
database access
GetMostExpensiveProducts - Creates a connection to the NorthWind
database and executes the
[Ten Most Expensive] stored procedure

I have found that if I allow the default credentials to go through, both
calls work correctly. However, when I create a set of credentials from
the login screen, the GetMessage shows the proper username (in
domain\username form) but the GetMostExpensiveProducts call errors with
the following error message:
Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

The GetMostExpensiveProducts has the following connection string:
"Provider=SQLOLEDB;Data Source=Dev2k;Initial Catalog=Northwind;
Integrated Security=SSPI;Trusted_Connection=yes"

The code on the client to create and set the credentials looks like this:
Dim _NWInfo As iNWInfo
Dim serverCredentials As New NetworkCredential
Dim channelproperties As IDictionary
Dim serverURL As String =
"http://localhost/dotNET/RemotingTest/NWInfo.rem"

...

_NWInfo =
CType(Activator.GetObject(GetType(RemotingInterfac e.iNWInfo), serverURL),
RemotingInterface.iNWInfo)

channelproperties =
ChannelServices.GetChannelSinkProperties(_NWInfo)
'Comment out the next line to cause 401 error and force manual
login to happen
'channelproperties("credentials") =
CredentialCache.DefaultCredential

Try
txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMessage
Catch ex As System.Net.WebException When ex.Message.indexof("401")
> 0

Dim loginDlg As New Login
loginDlg.ShowDialog()
If loginDlg.DialogResult = Windows.Forms.DialogResult.OK Then
serverCredentials.UserName = loginDlg.txtUserName.Text
serverCredentials.Password = loginDlg.txtPassword.Text
serverCredentials.Domain = loginDlg.txtDomain.Text
loginDlg.Close()
End If
channelproperties("credentials") = serverCredentials

txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMessage
Catch ex As System.Net.WebException When ex.Message.IndexOf("could
not be resolved") > 0
txtResults.Text += vbCrLf & "I couldn't find the server you
specified: " & serverURL
Catch ex As Exception
txtResults.Text = txtResults.Text & vbCrLf & ex.Message &
vbCrLf & ex.Source & vbCrLf & _
GetType(Exception).ToString
End Try
txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMessage

Can anyone tell me what I am doing wrong here?

TIA
Ron L

Nov 23 '05 #3

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

Similar topics

0
by: Linesh Gajera | last post by:
Hi, I have unique problem. I have configured RemotingServer running as Console Application and my Remoting object access Oracle database. My remoting object make call to Oracle database and...
0
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool This article makes a detailed comparison among SourceAnyWhere, SourceOffSite, VSS...
1
by: Ron L | last post by:
I am trying to setup a solution that will include a client which will access a database via remoting calls. I am hosting my remoting project in IIS, and am using Windows Integrated security. ...
5
by: mayamorning123 | last post by:
A comparison among six VSS remote tools including SourceOffSite , SourceAnyWhere, VSS Connect, SourceXT, VSS Remoting, VSS.NET To view the full article, please visit...
0
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed...
1
by: Buzz Bonner | last post by:
Hi, We have developed a distributed system that uses multiple .NET remoting servers hosted by Windows Services. However, the single server used for performing all database access using ADO.NET...
0
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool This article makes a detailed comparison among SourceAnyWhere, SourceOffSite, VSS...
5
by: Wendy Elizabeth | last post by:
I want a Visual Basic 6.0 web or desk top application to communicate with a Visual Basic.NET web or desktop application. I also want a Visual Basic.NET web or windows application to communicate...
1
by: miha.valencic | last post by:
Hi! What are the options for securing remote objects, which are accessible through IIS, when you have an application deployed on the same server, which uses custom Forms authentication? ...
13
by: Ron L | last post by:
I am working on an application that is a front-end for a SQL database. While it is not an immediate requirement, the application will probably be required to be able to connect via the internet at...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.