Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Change user password in ADS and check the domain password policy (C#)?

1,617 views
Skip to first unread message

Volkan Senguel

unread,
Aug 23, 2009, 4:22:51 PM8/23/09
to
Hi, im creating a app where the user can change his password, so far so
good.
Now, we have on our domain a password policy which means that passwords are
stored 12 time, the password must be changed on every 60 days and uses
complex passwords etc...

But if i change the password to the same password, i can do that without any
"error" message!?!?

How can i archive that the password policy is checked and a message is given
back with a human readable text?

========================================================================================================
string message = "";
string LDAPPath = getDistinguishedName(LogonName);

try
{
DirectoryEntry deUser = new DirectoryEntry("LDAP://" +
Properties.Settings.Default.DomainFull + "/" + LDAPPath, adUser,
adPassword);
deUser.CommitChanges();
deUser.Invoke("SetPassword", Password);
deUser.CommitChanges();
message = "Password updated!";
}
catch (DirectoryServicesCOMException ex)
{
message = "ERROR: + ex.InnerException;
}

if(message.Contains("0x80072035"))
{
message = "INFO: The password doesn't meet the
requirements!";
}

return message;
========================================================================================================

I need a way to check:
- has the password the minimum lenght
- is complex enough
- are not used for the last x passwords (password cache)

???

Thank you for any help
Volkan



Richard Mueller [MVP]

unread,
Aug 23, 2009, 8:19:36 PM8/23/09
to
If you use the ChangePassword method rather than SetPassword, the user must
provide the old password and the new password will be checked against the
domain policy.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--

"Volkan Senguel" <volkan....@networkpixel.com> wrote in message
news:uWRn%239CJK...@TK2MSFTNGP03.phx.gbl...

Volkan Senguel

unread,
Aug 24, 2009, 2:32:30 AM8/24/09
to
Thank you Richard, i have tryed with the ChangePassword method and i got
this error message each time :(

"Exception has been thrown by the target of an invocation" @
"System.DirectoryServices"


at the line > deUser.Invoke("ChangePassword", Password);

?
any ideas?

thx
Volkan


"Richard Mueller [MVP]" <rlmuelle...@ameritech.nospam.net> schrieb im
Newsbeitrag news:uGI1RCFJ...@TK2MSFTNGP02.phx.gbl...

Richard Mueller [MVP]

unread,
Aug 24, 2009, 10:10:34 AM8/24/09
to
ChangePassword requires two parameters, the old password and the new. This
link may help:

http://msdn.microsoft.com/en-us/library/ms180896.aspx

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--

"Volkan Senguel" <volkan....@networkpixel.com> wrote in message

news:%23zwepSI...@TK2MSFTNGP03.phx.gbl...

0 new messages