Author: AkAlan | Posted on: 1/21/2011 2:58:21 PM | Views : 538

I have some code that returns my LastPasswordSet date when I use my administrator account on my development machine using localhost but when I deploy to me test server and I get an exception "Object reference not set to an instance of an object"
Public Function GetUserPaswordExpiration() As Integer Dim currUser As String = CurrentLogin() Dim ctx As PrincipalContext = New PrincipalContext(ContextType.Domain, "ars") Dim currLogin As UserPrincipal = UserPrincipal.FindByIdentity(ctx, currUser) Dim passwordLastSet As Date = currLogin.LastPasswordSet Dim daysSinceLastSet As Integer = DateDiff(DateInterval.Day, passwordLastSet, Now()) daysSinceLastSet = 120 - daysSinceLastSet Return daysSinceLastSet End Function Public Function CurrentLogin() As String Dim curruser As String = WindowsIdentity.Ge ...

Go to the complete details ...