Home All Groups Group Topic Archive Search About

How to show the windows 'Connect To' dialog from C#

Author
8 Nov 2006 7:16 PM
Brad Marshall
I am trying to build an application that uses Active Directory to perform
authorization and authentication. The client application is a windows forms
'smart client'. The client application needs to get the
System.Security.Principal.WindowsIdentity.GetCurrent().Token and send it to
the middle tier for authentication against role based security defined in
ADAM. This works fine when the user is signed into a domain that has been
provisioned in ADAM. This does not work for users that do not have a machine
joined to the domain. These users sign into a local account and that is what
is provied back from the call to GetCurrent().Token. For these users when I
get a reject back from the middle tier I want to show them the Windows
'Connect To' dialog and have it do its magic to have the user authenticate
against a domain and provide back the token from successfuly authenticating
against a domain and user that has been provisioned in ADAM. I am looking for
the same interaction that occurs when a user tries to access a windows share
and the account they are using is not authorized. I have been unable to find
this capabiltiy in the framework. I have also been unable to find this in the
Win32 API. Can this be done? I know that I could create my own dialog but I
would really prefer that this interaction takes place outside of my code and
that I do not have to maintain a users password inside the memory of my
application.
Thanks for taking the time to try to help.

Author
9 Nov 2006 4:17 PM
Henning Krause
Hello,

the Win32 method you are looking for is CredUIPromptForCredentials.

But in fact, it doesn't do the magic of performing the authentication - it
just displays the dialog and returns the username/password combination.
There are multiple wrappers out there on the internet. I myself have one on
my website (see http://www.infinitec.de/libraries/security/default.aspx).

Best regards,
Henning Krause

Show quoteHide quote
"Brad Marshall" <Brad Marsh***@discussions.microsoft.com> wrote in message
news:D90DAE3C-A875-40EB-87E9-48F6BA2483A4@microsoft.com...
>I am trying to build an application that uses Active Directory to perform
> authorization and authentication. The client application is a windows
> forms
> 'smart client'. The client application needs to get the
> System.Security.Principal.WindowsIdentity.GetCurrent().Token and send it
> to
> the middle tier for authentication against role based security defined in
> ADAM. This works fine when the user is signed into a domain that has been
> provisioned in ADAM. This does not work for users that do not have a
> machine
> joined to the domain. These users sign into a local account and that is
> what
> is provied back from the call to GetCurrent().Token. For these users when
> I
> get a reject back from the middle tier I want to show them the Windows
> 'Connect To' dialog and have it do its magic to have the user authenticate
> against a domain and provide back the token from successfuly
> authenticating
> against a domain and user that has been provisioned in ADAM. I am looking
> for
> the same interaction that occurs when a user tries to access a windows
> share
> and the account they are using is not authorized. I have been unable to
> find
> this capabiltiy in the framework. I have also been unable to find this in
> the
> Win32 API. Can this be done? I know that I could create my own dialog but
> I
> would really prefer that this interaction takes place outside of my code
> and
> that I do not have to maintain a users password inside the memory of my
> application.
> Thanks for taking the time to try to help.