469,361 Members | 2,289 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,361 developers. It's quick & easy.

Change windows user account password

Hi All,

Can any one tell me how to change windows user account password
by programmatically using C#? I don't have administrator privileges and I
want to change my account password by programmatically.

I will be thankful if you can provide a sample program.

Thanks in Advance,

Srikanth

Nov 16 '05 #1
4 24240
Hi Srikanth!

It's easy, just use the System.DirectoryServices namespace to invoke
IADsUser::SetPassword:

http://msdn.microsoft.com/library/de..._passwords.asp

ok,
aq

"Srikanth" <ta*****@inooga.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi All,

Can any one tell me how to change windows user account password by programmatically using C#? I don't have administrator privileges and I
want to change my account password by programmatically.

I will be thankful if you can provide a sample program.

Thanks in Advance,

Srikanth

Nov 16 '05 #2
Think you also have win32 NetUserSetInfo pinvoke.

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Srikanth" <ta*****@inooga.com> wrote in message
news:#G**************@TK2MSFTNGP09.phx.gbl...
Hi All,

Can any one tell me how to change windows user account password by programmatically using C#? I don't have administrator privileges and I
want to change my account password by programmatically.

I will be thankful if you can provide a sample program.

Thanks in Advance,

Srikanth


Nov 16 '05 #3
You can't call SetPassword if you are not an administrator! And that's what
OP said isn't it?

Willy.

"Ahmed Qurashi" <ah**********@gmail.com> wrote in message
news:un****************@TK2MSFTNGP11.phx.gbl...
Hi Srikanth!

It's easy, just use the System.DirectoryServices namespace to invoke
IADsUser::SetPassword:

http://msdn.microsoft.com/library/de..._passwords.asp

ok,
aq

"Srikanth" <ta*****@inooga.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi All,

Can any one tell me how to change windows user account

password
by programmatically using C#? I don't have administrator privileges and I
want to change my account password by programmatically.

I will be thankful if you can provide a sample program.

Thanks in Advance,

Srikanth


Nov 16 '05 #4

"Srikanth" <ta*****@inooga.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi All,

Can any one tell me how to change windows user account password
by programmatically using C#? I don't have administrator privileges and I
want to change my account password by programmatically.

I will be thankful if you can provide a sample program.

Thanks in Advance,

Srikanth


Use the System.DirectoryServices to change the password of a local user
account.

Something like this will do.

using System;
using System.DirectoryServices;
// correct the userPath!!!
string userPath = "WinNT://yourMachineName/someuser";
using (DirectoryEntry userEntry = new DirectoryEntry(userPath))
{
object[] password = new object[] {"newPwd", "oldPwd"};
object ret = userEntry.Invoke("ChangePassword", password );
userEntry.CommitChanges();
}

Willy.
Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Srikanth | last post: by
3 posts views Thread by Ching Liang | last post: by
2 posts views Thread by http://www.visual-basic-data-mining.net/forum | last post: by
1 post views Thread by Henry | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.