Re: Authenticate to a webservice by WindowsIdentity

From: William Stacey [MVP] (staceywREMOVE_at_mvps.org)
Date: 01/28/05


Date: Fri, 28 Jan 2005 09:50:17 -0500

Why not use WSE which has rich support for security tokens such as
UsernameTokens and SecurityContextTokens?

-- 
William Stacey, MVP
http://mvp.support.microsoft.com
<Ray@Alirezaei.com> wrote in message
news:uvDzWyOBFHA.2104@TK2MSFTNGP14.phx.gbl...
> I'd like to feed the output of this method which is of WindowsIdentity
Type
> to Webservice in a way.I just wondered if  the following statements do the
> same thing.
> >>>>>> 1) rService.Credentials = new
> >>>>>> System.Net.NetworkCredential("username","password","domainName");
> >>>>>> 2)rService.Credentials =
> >>>>>> System.Net.CredentialCache.DefaultCredentials;
>
> thanks,
> ALI-R
>
> "Dilip Krishnan" <dkrishnan@NOSPAM.geniant.com> wrote in message
> news:229175632424486603471104@msnews.microsoft.com...
> > Hello ALI-R,
> >
> >   Not sure I follow what you're trying to achieve... where do you hope
to
> > call the Createidentity method?
> > HTH
> > Regards,
> > Dilip Krishnan
> > MCAD, MCSD.net
> > dkrishnan at geniant dot com
> > http://www.geniant.com
> >
> >> Thanks ,I think I somehow underestood it.Correct me if I'm wrong
> >> please? Since we have enabled windows integrated authentication in our
> >> web service which is serverd by IIS ,using
> >>
> >>>>>> 1) rService.Credentials = new
> >>>>>> System.Net.NetworkCredential("username","password","domainName");
> >>>>>> 2)rService.Credentials =
> >>>>>> System.Net.CredentialCache.DefaultCredentials;
> >>>>>>
> >> Infact we are using **WindowsIdentity**  to authenticate to our
> >> webservice,right?
> >>
> >> What I was looking for is to authenticate to the webservice in
> >> something like where "LogonUser" is an API  which I can use in
> >> conjunction with the WindowsIdentity class to create a new temporary
> >> identity to impersonate with later   :
> >>
> >> public static WindowsIdentity CreateIdentity(string User, string
> >> Domain,
> >> string Password)
> >> {
> >> // The Windows NT user token.
> >> IntPtr tokenHandle = new IntPtr(0);
> >> const int LOGON32_PROVIDER_DEFAULT = 0;
> >> const int LOGON32_LOGON_NETWORK_CLEARTEXT = 3;
> >> tokenHandle = IntPtr.Zero;
> >>
> >> // Call LogonUser to obtain a handle to an access token.
> >> bool returnValue = LogonUser(User, Domain, Password,
> >> LOGON32_LOGON_NETWORK_CLEARTEXT,
> >> LOGON32_PROVIDER_DEFAULT,
> >> ref tokenHandle);
> >> if (false == returnValue)
> >> {
> >> int ret = Marshal.GetLastWin32Error();
> >> throw new Exception("LogonUser failed with error code:
> >> " +
> >> ret);
> >> }
> >> //The WindowsIdentity class makes a new copy of the token.
> >> //It also handles calling CloseHandle for the copy.
> >> WindowsIdentity id = new WindowsIdentity(tokenHandle);
> >> CloseHandle(tokenHandle);
> >> return id;
> >> }
> >> Thanks again,
> >> Ali-R
> >> "Dilip Krishnan" <dkrishnan@NOSPAM.geniant.com> wrote in message
> >> news:227216632424123641457360@msnews.microsoft.com...
> >>
> >>> Hello ALI-R,
> >>> ws = web service. In your case web page as such is protected by IIS
> >>> (read
> >>> transport level). WS-Security gives you message level
> >> authentication/integrity/confidentiality
> >>
> >>> (has nothing to do with IIS or http). When you set the credentials
> >>> you are actually using windows/basic authentication supported by IIS.
> >>>
> >>> HTH
> >>> Regards,
> >>> Dilip Krishnan
> >>> MCAD, MCSD.net
> >>> dkrishnan at geniant dot com
> >>> http://www.geniant.com
> >>>> what do you mean by they don't use windows security?
> >>>>
> >>>> Thanks
> >>>> "Dilip Krishnan" <dkrishnan@NOSPAM.geniant.com> wrote in message
> >>>> news:222455632423579221519936@msnews.microsoft.com...
> >>>>> Hello ALI-R,
> >>>>> Both the methods you suggested use windows identity to
> >>>>> authenticate!
> >>>> Only
> >>>>
> >>>>> they dont use ws security. They use IIS authentication.
> >>>>>
> >>>>> HTH
> >>>>> Regards,
> >>>>> Dilip Krishnan
> >>>>> MCAD, MCSD.net
> >>>>> dkrishnan at geniant dot com
> >>>>> http://www.geniant.com
> >>>>>> I know how to authenticate to a webservice using either of these
> >>>>>> ways(Assuming  that rService represents the webservice):
> >>>>>>
> >>>>>> 1) rService.Credentials = new
> >>>>>> System.Net.NetworkCredential("username","password","domainName");
> >>>>>> 2)rService.Credentials =
> >>>>>> System.Net.CredentialCache.DefaultCredentials;
> >>>>>>
> >>>>>> My question is that is there a way to authenticate to a user using
> >>>>>> WindowsIdentity ???
> >>>>>>
> >>>>>> Thanks for your help
> >>>>>>
> >
> >
>
>


Relevant Pages

  • Re: Authentication Nightmare
    ... non asp.net file IIS security takes over. ... > impersonating the user and trying to redirect to their personal directory. ... > WindowsIdentity widTempIdentity = new WindowsIdentity; ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: User.IsInRole is always FALSE
    ... By default this would be ASPNET on IIS 5.0. ... application to run under a different account in IIS. ... >> WindowsIdentity windowsIdentity = ... >>> Microsoft Certified Application Developer ...
    (microsoft.public.dotnet.security)
  • Re: Role based security flaw?
    ... WindowsIdentity can't be faked (unless you start hacking with a debugger or ... security, it is harder to fake and probably easier to deal with. ... possibility of your local code that does that check getting hoisted, ... sounds like you are mostly interested in keeping the honest people honest, ...
    (microsoft.public.dotnet.security)
  • Re: Determine if IdentityReference is a Security Group
    ... bins to enforce Windows Security business logic (order of Allow/Deny ... Allow and Deny are easily obtained from IdentityReference. ... However, given an IdentityReference (or SID), ... WindowsIdentity will give me a list of the user's groups. ...
    (microsoft.public.dotnet.security)
  • Re: Why cant access a file under mapped network drive from Web Se
    ... WindowsIdentity newId = new WindowsIdentity( ... Which is exactly my log-on impersonate. ... > 1) Change the rights that the user ASPNET has. ... Better than 1) but still a big security risk. ...
    (microsoft.public.dotnet.general)