AD LDS Unable to Change Password of a user

  • Thread starter Thread starter Vorale
  • Start date Start date
V

Vorale

Guest
I am using an ASP.NET C# web page to have the users change the password themselves. The users are based on AD LDS, which is using port 50405. AD is on the same machine using port 389.


I read through a lot of web pages talking about the exceptions that pop up when invoke "SetPassword" or "ChangePassword", and I got the same: 0x80072020.

Here is my code:

const int ADS_OPTION_PASSWORD_PORTNUMBER = 6;
const int ADS_OPTION_PASSWORD_METHOD = 7;
const int ADS_PASSWORD_ENCODE_CLEAR = 1;

try
{
DirectoryEntry root = new DirectoryEntry(
ADAMPath,
ADAMAdminDN,
ADAMAdminPwd,
AuthenticationTypes.Delegation | AuthenticationTypes.None
);

using (root)
{
DirectorySearcher searcher = new DirectorySearcher(root,
string.Format("(CN={0})", username)
);
var result = searcher.FindOne();
if (result != null)
{
var user = result.GetDirectoryEntry();
string userDN = (string)(user.Properties["distinguishedName"].Value);

try
{
//user = new DirectoryEntry(result.Path, ADAMAdminDN, ADAMAdminPwd, AuthenticationTypes.ServerBind);

user.RefreshCache();
int intPort = 50405;
user.Invoke("SetOption", new object[] { ADS_OPTION_PASSWORD_PORTNUMBER, intPort });
user.Invoke("SetOption", new object[] { ADS_OPTION_PASSWORD_METHOD, ADS_PASSWORD_ENCODE_CLEAR });

user.Invoke("ChangePassword", new object[] { password, npassword });
//user.Invoke("SetPassword", new object[] { npassword });
user.Properties["LockOutTime"].Value = 0;
user.CommitChanges();
}
catch (Exception e)
{
string innerMsg = e.InnerException.Message;
return false;
}
}
}
return true;
}
catch (Exception ex)
{
return false;
}


Can anyone help me on this issue? Is there any thing that need to change on user settings?

And another question: is it a must to use SSL when changing password?


Jeff Zhang Home & Small Business Server SDET

Continue reading...
 
Back
Top