c# .NET Active Directory user retrieval throws exception when user password is in the expiry warning period -


when checking if user in role, typically use following type of code. however, code throws exception if user warned password expire in next 10 days (for example). know way prevent happening?

using system.security.principal; . . . public userdto getcurrentuser() {     userdto u = new userdto();      // grab windows information     windowsidentity currentuseridentity = windowsidentity.getcurrent();     windowsprincipal currentuserprincipal = new windowsprincipal(currentuseridentity);     u.isauthorized = currentuserprincipal.isinrole("mydomain\\myrole");     u.name = currentuseridentity.name;      if (u.isauthorized)     {         u.id = 1;     }     else // user isn't authorized     {         u.id = 0;     }     return u;  } // current user 

i'm using .net framework 4.5 code.

thanks! ray


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -