I want to reset the Password of users of Company 2 who are in Windows NT domain with a web application using ASP.NET 1.1 with C#.
Is the below code works fine or do I need to try some thing else, please helps me with this request.

DirectoryEntry de = GetDirectoryObject();
DirectorySearcher deSearch = new DirectorySearcher();
deSearch.SearchRoot = de;
deSearch.Filter = "(&(objectClass=user)(sAMAccountName=" + UserName + "))";
deSearch.SearchScope = SearchScope.Subtree;
SearchResult results = deSearch.FindOne();
if (!(results == null))
{
de = new DirectoryEntry(results.Path);
return de;
}
else
{
return null;
}
}



/// <summary>
/// This method enables account in AD
/// </summary>
/// <param name="oDE">directoryEntry - oDE</param>
private void EnableUserAccount(DirectoryEntry oDE)
{
oDE.Properties["userAccountControl"].Value = _userStatus.Enable;
oDE.CommitChanges();
oDE.Close();
}

/// <summary>
/// This method enables resetting password on next login
/// </summary>
/// <param name="oDE">directoryEntry - oDE</param>
private void EnableResetPasswordNextLogin(DirectoryEntry oDE)
{
oDE.Properties["pwdLastSet"].Value = 0;
oDE.CommitChanges();
oDE.Close();
}

/// <summary>
/// This method resets user password
/// </summary>
/// <param name="oDE">directoryEntry - oDE</param>
/// <param name="Password">string NewPassword</param>
private void SetUserPassword (DirectoryEntry oDE, string Password)
{
object ret = oDE.Invoke("SetPassword", new object[] {Password});
}

/// <summary>
/// This method enables account in AD
/// </summary>
/// <param name="userName">string userName</param>
public void EnableUserAccount(string userName)
{
try
{
EnableUserAccount(GetUser(userName));
}
catch(Exception ex)
{
log.Error(ex);
throw;
}

}

/// <summary>
/// This method enables resetting password on next login
/// </summary>
/// <param name="userName">string username</param>
public void EnableResetPasswordNextLogin(string userName)
{
try
{
EnableResetPasswordNextLogin(GetUser(userName));
}
catch(Exception ex)
{
log.Error(ex);
}

}

/// <summary>
/// This method sets new password in AD
/// </summary>
/// <param name="userName">string Username</param>
/// <param name="newPassword">string Password</param>
public void SetPassword(string userName, string newPassword)
{
try
{
DirectoryEntry de = GetUser(userName);
SetUserPassword(de, newPassword);
de.CommitChanges();
}
catch(Exception ex)
{
log.Error(ex);
throw;
}

}

References:

Overview:

I have two companies in the Network Diagram Company one is on Windows NT 4.0 setup and Company 2 on Windows 2000 setup. The servers in company 2 are 2000 (service pack 4) using Active Directory in native mode (Not Mixed Mode) with sites/subnets/branch.

Password policy:

How many characters are required for password? (Min/Max) 8/14
Is the account reset for the user to change password at first logon? This would have to be done manually by the help desk since accounts are set to automatically lock forever.
Any complexity rules applied Not natively supported by NT 4.0 unless the SP2 passfilt.dll has been applied, which it is not.
Password age/history? Minimum password age set to 3 days, history set to remember last 5 passwords
Is it a single domain model? Yes