I have a .NET MVC (1.0) application that is using the ActiveDirectoryMembershipProvider to authenticate users, and this is working fine as is. After a successful authentication, I am creating a custom profile in SQL for that user (AD username, email, etc).
In one part of the application I am sending email alerts to users, and I am looping though users from the local SQL table that holds the AD UserName, mentioned above. Prior to sending the alert, I would like to verify that the user we are sending to is still a valid (i.e. active) user in AD. How can I check this without the password of the current user in my loop?
I was hoping to do soemthing like this...
MembershipUser adUser= Membership.GetUser(userName); //I have the username from the loop
bool isValid = adUser.isValid; //I know this is not a real property
I know that there is no such property called "isValid" -- but does anyone know what property I should use? If MembershipUser is of no use, then I assume that I need to write some code invoking the System.DirectoryServices.ActiveDirectory namespace? If so, what property should I be checking in AD to see if the user is valid? And by "valid," I mean that the user still works for the company in question, and is able to sign-in via AD. I am not concerned with the user's group membership in AD.
Thanks,
Mike