set account expires in AD from FIM RRS feed

  • Question

  • I am setting accountExpires value using code mentioned below. Everything is good however, there is a difference in hours,

    minutes and second. Why it is so? I also tried using ToFileTimeUTC() but no luck.

    Tuesday, May 21, 2013 11:36 AM

All replies

  • Try this:

    CultureInfo provider = CultureInfo.InvariantCulture;
    switch (FlowRuleName.ToString().ToUpper())
        case "ACCOUNTEXPIRES":
            DateTime dtAccountExpires = DateTime.ParseExact(mventry["employeeEndDate"].Value, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.000'", provider);
            csentry["accountExpires"].IntegerValue = dtAccountExpires.ToFileTime();

    I think the ".fff" in your date format (commented code) is causing problems. the above will hardcode the milliseconds to zeros.

    Tuesday, May 21, 2013 12:28 PM
  • But that is commented. Do you believe it will make any difference? 
    Tuesday, May 21, 2013 12:34 PM
  • Without knowing the exact data contained in the "employeeEndDate" entry, it is hard to say if this will solve your issue. One usually checks for String.Empty, Zero and 9223372036854775807 - because they have special meaning.

    You may need to convert the DateTime value from Local to UTC (dtAccountExpires.ToUniversalTime()) after the ParseExact, depending on how they are stored in your environment.

    Tuesday, May 21, 2013 12:57 PM