Two problems with the code right off:
First, the username should be specified as "CN=xxxx", as the Add method with
the LDAP provider takes a relative distinguished name:
Dim NewUser As DirectoryEntry = AD.Children.Add("CN=TestUser1", "user")
Second, yu should save the user first before trying to set the password as
the object needs to be persisted to the directory before the password can be
set:
NewUser.CommitChanges()
NewUser.Invoke("SetPassword", "NewPassword")
Depending on whether the domain is AD 2000 or 2003, you may need to set the
sAMAccountName attribute before you do the initial save. 2003 will create a
default value, but 2000 will not. Note that using the default value is
probably a bad idea as that will essentially give the user a semi-random
logon name. I recommend always setting it explicitly.
NewUser.Properties("sAMAccountName").Value = "TestUser1"
If you want to make sure you use SSL to bind to the directory, make sure
AuthenticationTypes.SecureSocketsLayer is set on the parent object before it
is bound to the directory. Note that your AD must be configured with an SSL
certificate to use SSL/LDAP.
HTH,
Joe K.
> Hi,
> I've been trying to change the password of an active directory user
[quoted text clipped - 10 lines]
> Dim NewUser As DirectoryEntry = AD.Children.Add("TestUser1", "user")
> NewUser.Invoke("SetPassword", "NewPassword")
Natasja - 11 Oct 2005 16:03 GMT
Hi Joe,
how do I configure AD with an SSL certificate? Can you point me to any
documentation on how to set this up?
Thanks,

Signature
Natasja
> Two problems with the code right off:
>
[quoted text clipped - 41 lines]
> > Dim NewUser As DirectoryEntry = AD.Children.Add("TestUser1", "user")
> > NewUser.Invoke("SetPassword", "NewPassword")
Joe Kaplan (MVP - ADSI) - 11 Oct 2005 18:07 GMT
http://support.microsoft.com/default.aspx?scid=kb;en-us;247078
Google will turn up lots of other documents as well for configuring with
third party certificates and such.
Note that you may not need SSL support on your DC. SetPassword works best
with SSL support, but it does not absolutely require it. If you can get it
to work without SSL, you may be better off.
Joe K.
> Hi Joe,
>
[quoted text clipped - 58 lines]
>> > Dim NewUser As DirectoryEntry = AD.Children.Add("TestUser1", "user")
>> > NewUser.Invoke("SetPassword", "NewPassword")