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.Cur rent.User.Ident ity.Name but has no
database access
GetMostExpensiv eProducts - 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 GetMostExpensiv eProducts call errors with the following error
message:
Login failed for user 'NT AUTHORITY\ANONY MOUS LOGON'.
The GetMostExpensiv eProducts has the following connection string:
"Provider=SQLOL EDB;Data Source=Dev2k;In itial Catalog=Northwi nd;
Integrated Security=SSPI;T rusted_Connecti on=yes"
The code on the client to create and set the credentials looks like this:
Dim _NWInfo As iNWInfo
Dim serverCredentia ls As New NetworkCredenti al
Dim channelproperti es As IDictionary
Dim serverURL As String =
"http://localhost/dotNET/RemotingTest/NWInfo.rem"
...
_NWInfo =
CType(Activator .GetObject(GetT ype(RemotingInt erface.iNWInfo) , serverURL),
RemotingInterfa ce.iNWInfo)
channelproperti es =
ChannelServices .GetChannelSink Properties(_NWI nfo)
'Comment out the next line to cause 401 error and force manual login
to happen
'channelpropert ies("credential s") =
CredentialCache .DefaultCredent ial
Try
txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMess age
Catch ex As System.Net.WebE xception When ex.Message.inde xof("401") >
0
Dim loginDlg As New Login
loginDlg.ShowDi alog()
If loginDlg.Dialog Result = Windows.Forms.D ialogResult.OK Then
serverCredentia ls.UserName = loginDlg.txtUse rName.Text
serverCredentia ls.Password = loginDlg.txtPas sword.Text
serverCredentia ls.Domain = loginDlg.txtDom ain.Text
loginDlg.Close( )
End If
channelproperti es("credentials ") = serverCredentia ls
txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMess age
Catch ex As System.Net.WebE xception When ex.Message.Inde xOf("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(Excepti on).ToString
End Try
txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMess age
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.Cur rent.User.Ident ity.Name but has no
database access
GetMostExpensiv eProducts - 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 GetMostExpensiv eProducts call errors with the following error
message:
Login failed for user 'NT AUTHORITY\ANONY MOUS LOGON'.
The GetMostExpensiv eProducts has the following connection string:
"Provider=SQLOL EDB;Data Source=Dev2k;In itial Catalog=Northwi nd;
Integrated Security=SSPI;T rusted_Connecti on=yes"
The code on the client to create and set the credentials looks like this:
Dim _NWInfo As iNWInfo
Dim serverCredentia ls As New NetworkCredenti al
Dim channelproperti es As IDictionary
Dim serverURL As String =
"http://localhost/dotNET/RemotingTest/NWInfo.rem"
...
_NWInfo =
CType(Activator .GetObject(GetT ype(RemotingInt erface.iNWInfo) , serverURL),
RemotingInterfa ce.iNWInfo)
channelproperti es =
ChannelServices .GetChannelSink Properties(_NWI nfo)
'Comment out the next line to cause 401 error and force manual login
to happen
'channelpropert ies("credential s") =
CredentialCache .DefaultCredent ial
Try
txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMess age
Catch ex As System.Net.WebE xception When ex.Message.inde xof("401") >
0
Dim loginDlg As New Login
loginDlg.ShowDi alog()
If loginDlg.Dialog Result = Windows.Forms.D ialogResult.OK Then
serverCredentia ls.UserName = loginDlg.txtUse rName.Text
serverCredentia ls.Password = loginDlg.txtPas sword.Text
serverCredentia ls.Domain = loginDlg.txtDom ain.Text
loginDlg.Close( )
End If
channelproperti es("credentials ") = serverCredentia ls
txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMess age
Catch ex As System.Net.WebE xception When ex.Message.Inde xOf("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(Excepti on).ToString
End Try
txtResults.Text = txtResults.Text & vbCrLf & _NWInfo.GetMess age
Can anyone tell me what I am doing wrong here?
TIA
Ron L
Comment