473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to change the Active Directory user password?

Hi all,
How can I modify users in Active Directory ? Actually , I want to change the
Active Directory user password . But how can I do that?
Nov 16 '05 #1
11 31887
You can use something like the following

DirectoryEntry deUser = new
DirectoryEntry("LDAP://CN=TestUser,CN=Users,DC=TestDomain,DC=com");
deUser.Invoke("SetPassword", "NewPassword");
deUser.CommitChanges();

Cheers,
John Wadie

Nov 16 '05 #2
Thanks.
But I was comfused about the method name SetPassword. Where is this
method come from? This method no need to delecare?
How many methods I can use by DirectoryEntry? What are their name?
I know DirectoryEntry.Invoke() is a delegate,and as I know a delegate
object must "link" a method which they are in the same type and provide
the same parameter.
But in your code, I can't see any delecare about SetPassword.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
What makes you think DirectoryEntry.Invoke is a delegate?
It's a regualr method that calls a method (here SetPassword) on the native
COM IADs interface using reflection.
Call it like this:
userEntry.Invoke("SetPassword", object[] {"secret"});

Willy.

"Jet Leung" <xi**@tom.com> wrote in message
news:uy**************@TK2MSFTNGP14.phx.gbl...
Thanks.
But I was comfused about the method name SetPassword. Where is this
method come from? This method no need to delecare?
How many methods I can use by DirectoryEntry? What are their name?
I know DirectoryEntry.Invoke() is a delegate,and as I know a delegate
object must "link" a method which they are in the same type and provide
the same parameter.
But in your code, I can't see any delecare about SetPassword.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #4
It's because programming ADSI from C# can be a right royal pain in the
rear end. Most of the ADSI functionality is still in COM, and it's a
bit of a quirky API to start with - even from late bound VBScript.

There is a list of examples here:

Quick List for C# Code Examples
http://msdn.microsoft.com/library/de...e_examples.asp

This includes how to change passwords, and how to use Invoke and
InvokeMember.

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 14 Oct 2004 09:13:49 -0700, Jet Leung <xi**@tom.com> wrote:
Thanks.
But I was comfused about the method name SetPassword. Where is this
method come from? This method no need to delecare?
How many methods I can use by DirectoryEntry? What are their name?
I know DirectoryEntry.Invoke() is a delegate,and as I know a delegate
object must "link" a method which they are in the same type and provide
the same parameter.
But in your code, I can't see any delecare about SetPassword.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 16 '05 #5
Thanks
Because if delcare a delegate , it can invoke methods like
a.invoke("method name","parameters"),so when I saw the code like this I
think it is delegate.
In C# DirectoryEntry ,Am I use any ADSI methods and no need to delcare
any object ?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #6
You still need to declare objects and sometimes even create a new
instance. You should work through some of the examples in the link I
sent in the last post, I'm sure they can help you out.

--
Scott
http://www.OdeToCode.com/

On Thu, 14 Oct 2004 18:33:26 -0700, Jet Leung <xi**@tom.com> wrote:
Thanks
Because if delcare a delegate , it can invoke methods like
a.invoke("method name","parameters"),so when I saw the code like this I
think it is delegate.
In C# DirectoryEntry ,Am I use any ADSI methods and no need to delcare
any object ?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 16 '05 #7
Thank you !
But I still don't know how to make the IADsUser link the DirectoryEntry
object
this is my code
========
Microsoft.SharePoint.SPWeb
_spweb=Microsoft.SharePoint.WebControls.SPControl. GetContextWeb(this.Con
text);
Microsoft.SharePoint.SPUser _spuser=_spweb.CurrentUser;
m_sCurrentLoginUser=_spuser.LoginName;
ActiveDs.IADsUser _user=(ActiveDs.IADsUser)_spuser;
DirectoryEntry de=new DirectoryEntry(Path);
de.Invoke("_user.ChangePassword",new object[]{m_txtOldPwd.Text
,m_txtNewPwd.Text});
de.CommitChanges();

please tell me the right way and the real sample code
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #8
Hi Jet:

I'm afraid I don't have any experience with SharePoint at this time,
but I doubt you can cast an SPUser to an IADsUser. You probably want
to extract information about the user to build the path parameter for
the DirectoryEntry.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 15 Oct 2004 00:13:16 -0700, Jet Leung <xi**@tom.com> wrote:
Thank you !
But I still don't know how to make the IADsUser link the DirectoryEntry
object
this is my code
========
Microsoft.SharePoint.SPWeb
_spweb=Microsoft.SharePoint.WebControls.SPControl .GetContextWeb(this.Con
text);
Microsoft.SharePoint.SPUser _spuser=_spweb.CurrentUser;
m_sCurrentLoginUser=_spuser.LoginName;
ActiveDs.IADsUser _user=(ActiveDs.IADsUser)_spuser;
DirectoryEntry de=new DirectoryEntry(Path);
de.Invoke("_user.ChangePassword",new object[]{m_txtOldPwd.Text
,m_txtNewPwd.Text});
de.CommitChanges();

please tell me the right way and the real sample code
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 16 '05 #9
Thanks a lot!
Maybe.. Could you show me the real sample code to change Active
Directory User's password without SharePoint?
I have try that but failed! I don't know how the IADsUser create
relationship with the DirectoryEntry.And how the DirectoryEntry object
can use the method of the IADsUser interface.
Thank you very much!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #10
Hi Jet:

IF you send me an email, I can get some code to you on Monday when I'm
finished travelling

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 15 Oct 2004 10:13:36 -0700, Jet Leung <xi**@tom.com> wrote:
Thanks a lot!
Maybe.. Could you show me the real sample code to change Active
Directory User's password without SharePoint?
I have try that but failed! I don't know how the IADsUser create
relationship with the DirectoryEntry.And how the DirectoryEntry object
can use the method of the IADsUser interface.
Thank you very much!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 16 '05 #11
Hi Scott,
I had sent email on your blog.
Please send me some codes to direct me to finish my work.
Thank you!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mario Rodriguez | last post by:
Hi people, Does anyone have some idea how to get the password of an active directory user? I tried using the DirectorySearcher object to find the user and the DirectoryEntry.Password property to...
0
by: S Lemen | last post by:
Hi, How are Active Directory user object attributes removed in VB .Net? The remove method succeeds but the CommitChanges errors with: "The attribute syntax specified to the directory service...
0
by: Kooki | last post by:
Hi, I am developing a small programme to add ACTIVE DIRECTORY users to another server. everything works fine .. I get the users from AD using LDAP but while adding users I need to get the user...
0
by: Kooki | last post by:
Hi, I am developing a small programme to add ACTIVE DIRECTORY users to another server. everything works fine .. I get the users from AD using LDAP but while adding users I need to get the user...
6
by: jarice1978 | last post by:
Hello, I have been scanning the internet for a few days now. That is not working. So now it is time to post! I have read a few other posts on here about authentication but they do not match...
3
by: Chris Noble | last post by:
I need to be able to read and add to the collection of email addesses for an Active Directory User with a mailbox. I assume that this is a collection object. However I can't find any help on which...
7
by: Vio | last post by:
Hello everyone, i currently a beginner in php. I want to ask about Win2003 Active Directory users. Is it possible to retrieve Win2003 AD (just username & password) with php. I'm currenty...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.