In the same ballpark, here's what I do after the account has been created.
Web.config "account impersonate" comes to mind also, but that (or
equivalent) should already be in place if you're able to create the users, I
believe.
Const UF_DONT_EXPIRE_PASSWD = 6553
Const UF_PASSWD_CANT_CHANGE = 64
Dim user As IADsUser
user = GetObject("WinNT://servernamehere/" + txtUN.Text + ",user")
user.AccountDisabled = False
user.SetInfo()
Dim lUserFLags = user.Get("userFlags")
lUserFLags = lUserFLags Or UF_PASSWD_CANT_CHANGE
lUserFLags = lUserFLags Or UF_DONT_EXPIRE_PASSWD
user.Put("userFlags", lUserFLags)
user.SetInfo()
user.SetPassword(txtPassword.Text)
user.SetInfo()
From: ADSIANDDirectoryServices@yahoogroups.com
[mailto:ADSIANDDirectoryServices@yahoogroups.com] On Behalf Of tarakvbhatt
Sent: Wednesday, December 17, 2008 11:34 PM
To: ADSIANDDirectoryServices@yahoogroups.com
Subject: [ADSI-DirSrv] Set Active Directory User Password
Can anyone here let me know how to Set newly created AD User's
Password ?
Actually I am creating a new user in Active Directory using my C#
code.
It is created successfully.
Now when I tried to Set the Password of that newly created user , it
gives me an exception message as follows:
"Exception has been thrown by the target of an invocation."
The InnerException message is as follows:
"The network path was not found. (Exception from HRESULT: 0x80070035)"
The C# code I am using to Set Password is as follows :
-------------------------------------------------------
DirectoryEntry parent = new DirectoryEntry
("RootLDAPPath", "username", "password", AuthenticationTypes.Secure);
DirectoryEntry ouCustomer = parent.Children.Find("OU=Customers");
DirectoryEntry user = ouCustomer.Children.Find
("CN=testinguser", "user");
user.AuthenticationType = AuthenticationTypes.Secure;
user.Invoke("SetPassword", new object[] { "wohkaun@123" });
user.CommitChanges();
---------------------------------------------------------------------------
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential or privileged material.
Any review, retransmission, dissemination or other use of, or taking of any
action in reliance upon, this information by persons or entities other than
the intended recipient is prohibited. If you received this in error, please
notify the sender and delete the material from your computer.
---------------------------------------------------------------------------
[Non-text portions of this message have been removed]