"Mustafa Rabie" <mr*******@hotmail.com> wrote in message
news:u$**************@TK2MSFTNGP14.phx.gbl...
Dear All,
I am writing a windows c# application, where it needs to make sure that
the currently logged on user is Active Dicrectory Authenticated. I looked
on the internet and found authentication for ASP.Net but not windows apps,
can someone point me to some code or links where i can find how this can
be reached?
Thanks
Mustafa
If the current user is logged on using his domain credentials he is AD
authenticated, right.
So it's just a matter of checking his role membership.
AppDomain myDomain = Thread.GetDomain();
myDomain.SetPrincipalPolicy(PrincipalPolicy.Window sPrincipal);
WindowsPrincipal myPrincipal =
(WindowsPrincipal)Thread.CurrentPrincipal;
try {
if( myPrincipal.IsInRole("us*******@xxx.yyy.zzz"))
// domain member and in role ("usergoroup" member)
else
// domain member but not in role (not a "usergroup" member)
}
catch(...) // If exception - CurrentPrincipal is no xxx.yyy.zzz
domain member
Willy.