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

Multilayer CSV to filtered excel -

Listboxes in c# -

ios - Why must I define variables twice in the Header file? -