Changing a limited user account in XP fails
- by javamonkey79
I have the following:
using System;
using System.DirectoryServices.AccountManagement;
public class ChangePassword
{
public static void Main()
{
PrincipalContext context = new PrincipalContext(ContextType.Machine);
UserPrincipal user = UserPrincipal.FindByIdentity(context, "someLimitedAccount");
user.ChangePassword( "xxx", "zzz" );
}
}
This works just fine with administrator accounts, but seems to crash like so when I try to change limited accounts in XP:
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at ChangePassword.Main()
Is what I am trying to do possible? If so, how?
EDIT #1:
I added the following:
Console.WriteLine( "user: " + user );
Below this line:
UserPrincipal user = UserPrincipal.FindByIdentity(context, "someLimitedAccount");
And I get this:
user:
It doesn't look like user is null when I print it, but then again I'm not really a .Net guy - I seem to remember this being expected behavior.