Search the web
Sign In
New User? Sign Up
ADSIANDDirectoryServices · ADSI and System.DirectoryServices Q&A
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Set Active Directory User Password   Message List  
Reply | Forward Message #4590 of 4632 |
RE: [ADSI-DirSrv] Set Active Directory User Password

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]




Thu Dec 18, 2008 3:31 pm

araczynski
Offline Offline
Send Email Send Email

Forward
Message #4590 of 4632 |
Expand Messages Author Sort by Date

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...
tarakvbhatt
Offline Send Email
Dec 18, 2008
5:33 am

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...
Andrzej Raczynski
araczynski
Offline Send Email
Dec 18, 2008
3:31 pm

T, See code example that creates AD user and sets password. It's VBA, but still using ADSI: ...
Robert Lawson
trev3411
Offline Send Email
Dec 18, 2008
4:14 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help