NetworkCredential based on DefaultCredentials

P

Peter Lapic

I am running an VB.Net app which calls an ASP.Net Web Service and this
service accesses SQL Server.
The Web Service & SQL Server run on separate Windows 2000 server on the same
domain.
As we don't use Kerberos, the only means to flow the original user
credentials from the VB.Net app right thru to SQL Server is to set the web
service object credentials parameter in the VB.Net app.

The credentials is created based on the following code
oCredentials.Add(New Uri(oRollOrderAutomation.Url), "Basic", New
System.Net.NetworkCredential(InputBox("Enter Windows Login Name: ",
"Username", "my login"), InputBox("Enter Windows Password: ", "Password",
"my password"), "my domain"))

Without prompting the user to rekey their windows username & password is
there some way to pass the current windows network connection to the
credentials object?

Regards

Peter
 
Y

Yan-Hong Huang[MSFT]

Hello Peter,

Thanks for posting in the group.

After reviewing the question, I feel you want to get the current credential
of VB.NET app programmatically and use it to access web service. Please
correct me if I have misunderstood the question.

Based on my experience, we could use CredentialCache.DefaultCredentials to
get the system credentials for the current security context in which the
application is running. So you could try to use it in code to see if it
works under this situation.

Dim a As New server.Service1()
a.Credentials = CredentialCache.DefaultCredentials;
MessageBox.Show(a.HelloWorld()) // Call the web service

Does that answer your question?

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "Peter Lapic" <[email protected]>
!Subject: NetworkCredential based on DefaultCredentials
!Date: Mon, 20 Oct 2003 15:18:10 +1000
!Lines: 27
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <[email protected]>
!Newsgroups: microsoft.public.dotnet.languages.vb
!NNTP-Posting-Host: 61.88.149.94
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:148303
!X-Tomcat-NG: microsoft.public.dotnet.languages.vb
!
!I am running an VB.Net app which calls an ASP.Net Web Service and this
!service accesses SQL Server.
!The Web Service & SQL Server run on separate Windows 2000 server on the
same
!domain.
!As we don't use Kerberos, the only means to flow the original user
!credentials from the VB.Net app right thru to SQL Server is to set the web
!service object credentials parameter in the VB.Net app.
!
!The credentials is created based on the following code
!oCredentials.Add(New Uri(oRollOrderAutomation.Url), "Basic", New
!System.Net.NetworkCredential(InputBox("Enter Windows Login Name: ",
!"Username", "my login"), InputBox("Enter Windows Password: ", "Password",
!"my password"), "my domain"))
!
!Without prompting the user to rekey their windows username & password is
!there some way to pass the current windows network connection to the
!credentials object?
!
!Regards
!
!Peter
!
!
!
!
!
!
!
 
P

Peter Lapic

Actually that was my first approach and this uses NTLM as
the authentication type. Whilst connecting to the Web
Service was fine, the connection to SQL Server from the
Web Service failed. Apparently this is a delegation issue
and because we don't have AD and Kerberos my other choice
was to use Basic Authentication.

I tried to pass the DefaultCredentials as oCredentials.Add
(New Uri(oRollOrderAutomation.Url), "Basic",
CredentialCache.DefaultCredentials) but I got an error
saying Default credentials cannot be supplied for this
particular authentication type.

I am not using anonymous access in IIS as this defeats
the purpose of identifying the actual user in SQL Server.

Regards
Peter
-----Original Message-----
Hello Peter,

Thanks for posting in the group.

After reviewing the question, I feel you want to get the current credential
of VB.NET app programmatically and use it to access web service. Please
correct me if I have misunderstood the question.

Based on my experience, we could use
CredentialCache.DefaultCredentials to
get the system credentials for the current security context in which the
application is running. So you could try to use it in code to see if it
works under this situation.

Dim a As New server.Service1()
a.Credentials = CredentialCache.DefaultCredentials;
MessageBox.Show(a.HelloWorld()) // Call the web service

Does that answer your question?

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "Peter Lapic" <[email protected]>
!Subject: NetworkCredential based on DefaultCredentials
!Date: Mon, 20 Oct 2003 15:18:10 +1000
!Lines: 27
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <[email protected]>
!Newsgroups: microsoft.public.dotnet.languages.vb
!NNTP-Posting-Host: 61.88.149.94
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl! TK2MSFTNGP12.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:148303
!X-Tomcat-NG: microsoft.public.dotnet.languages.vb
!
!I am running an VB.Net app which calls an ASP.Net Web Service and this
!service accesses SQL Server.
!The Web Service & SQL Server run on separate Windows 2000 server on the
same
!domain.
!As we don't use Kerberos, the only means to flow the original user
!credentials from the VB.Net app right thru to SQL Server is to set the web
!service object credentials parameter in the VB.Net app.
!
!The credentials is created based on the following code
!oCredentials.Add(New Uri
(oRollOrderAutomation.Url), "Basic", New
 
Y

Yan-Hong Huang[MSFT]

Hello Peter,

That is correct. I discussed it with our colleagues. You can not pass the
the user token of current process or thread to the web
service. Current Framework only supports Basic and Digest authentic.

Dim a As New server.Service1()
Dim c As New CredentialCache()
c.Add(New Uri("http://server"), "Digest", New NetworkCredential("yhhuang",
"XXXXXXX", "domain"))
a.Credentials = c
MessageBox.Show(a.HelloWorld()) // Call the web service

So we have to pass our username and password manually under this situation.
Thanks very much and please feel free to post here if there is any unclear.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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