R
Ron L
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(RemotingInterface.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
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(RemotingInterface.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