473,395 Members | 1,466 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,395 software developers and data experts.

HOW Change Password

I need to change password of a local user of a W2003, without Active
Directory.
I need to do it from an application created with VB2005.

Thanks!
Jun 20 '06 #1
3 4164
On Tue, 20 Jun 2006 18:55:46 -0300, Xnet wrote:
I need to change password of a local user of a W2003, without Active
Directory.
I need to do it from an application created with VB2005.


Even if you do not have an active directory server, you can still change a
local user password with Active Directory (seems weird but it works). This
is C# code, sorry, but it should be straightforward enough to translate to
VB. Note that this is a "hardcore" reset of a user password so i'm not sure
of what would happen if the user had used Window's encryption mechanisms to
encrypt some of his personnal files (presumably, they'll be lost) or what
would happen if you try to change the password while the user is already
logged in. If you want to do a "nice" password change (that is, if you know
what the original password is), then there might be better ways of doing
it.

using System.DirectoryServices;

....

// That's the local Active Directory
DirectoryEntry localDirectory = new DirectoryEntry("WinNT://" +
Environment.MachineName + ",computer");

DirectoryEntry user = null;
string username = "John";
string password = "newPassword";

//Look for the user on the local machine
try
{
user = localDirectory.Children.Find(username, "user");
}

catch(Exception ex)
{
// This user doesn't exist or something went wrong

}

// Set the new password for this user
user.Invoke("SetPassword", new Object[] {password});
user.CommitChanges();
Jun 20 '06 #2
Work perfect for which it needed...

Thank you very much Mehdi !!!
"Mehdi" <vi****@REMOVEME.gmail.com> escribió en el mensaje
news:1w******************************@40tude.net.. .
On Tue, 20 Jun 2006 18:55:46 -0300, Xnet wrote:
I need to change password of a local user of a W2003, without Active
Directory.
I need to do it from an application created with VB2005.


Even if you do not have an active directory server, you can still change a
local user password with Active Directory (seems weird but it works). This
is C# code, sorry, but it should be straightforward enough to translate to
VB. Note that this is a "hardcore" reset of a user password so i'm not
sure
of what would happen if the user had used Window's encryption mechanisms
to
encrypt some of his personnal files (presumably, they'll be lost) or what
would happen if you try to change the password while the user is already
logged in. If you want to do a "nice" password change (that is, if you
know
what the original password is), then there might be better ways of doing
it.

using System.DirectoryServices;

...

// That's the local Active Directory
DirectoryEntry localDirectory = new DirectoryEntry("WinNT://" +
Environment.MachineName + ",computer");

DirectoryEntry user = null;
string username = "John";
string password = "newPassword";

//Look for the user on the local machine
try
{
user = localDirectory.Children.Find(username, "user");
}

catch(Exception ex)
{
// This user doesn't exist or something went wrong

}

// Set the new password for this user
user.Invoke("SetPassword", new Object[] {password});
user.CommitChanges();

Jun 20 '06 #3

Hi there

Can you please share the code, I am trying to implement something similar
but it seems to get stuck at the "SetPassword" line

Thanks in advance

"Xnet" wrote:
Work perfect for which it needed...

Thank you very much Mehdi !!!
"Mehdi" <vi****@REMOVEME.gmail.comescribió en el mensaje
news:1w******************************@40tude.net.. .
On Tue, 20 Jun 2006 18:55:46 -0300, Xnet wrote:
I need to change password of a local user of a W2003, without Active
Directory.
I need to do it from an application created with VB2005.
Even if you do not have an active directory server, you can still change a
local user password with Active Directory (seems weird but it works). This
is C# code, sorry, but it should be straightforward enough to translate to
VB. Note that this is a "hardcore" reset of a user password so i'm not
sure
of what would happen if the user had used Window's encryption mechanisms
to
encrypt some of his personnal files (presumably, they'll be lost) or what
would happen if you try to change the password while the user is already
logged in. If you want to do a "nice" password change (that is, if you
know
what the original password is), then there might be better ways of doing
it.

using System.DirectoryServices;

...

// That's the local Active Directory
DirectoryEntry localDirectory = new DirectoryEntry("WinNT://" +
Environment.MachineName + ",computer");

DirectoryEntry user = null;
string username = "John";
string password = "newPassword";

//Look for the user on the local machine
try
{
user = localDirectory.Children.Find(username, "user");
}

catch(Exception ex)
{
// This user doesn't exist or something went wrong

}

// Set the new password for this user
user.Invoke("SetPassword", new Object[] {password});
user.CommitChanges();


Aug 1 '06 #4

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

Similar topics

2
by: MLH | last post by:
What's the simplest way to allow a user of an A97 app to change password?
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
0
by: GregS | last post by:
We have a client that has a very large number of users that will be connecting back to the domain via VPN only. The problem is that the communications vendor can not pass the password expiration...
6
by: Jan | last post by:
Hi: I have created a secured database for a client. For various reasons, I don't want the client to have full persmissions for the database; they aren't in the admins group. I have instead tried...
2
by: J | last post by:
Hello. I apologize if this isn't the appropriate group for this question but I was wondering if it's possible to allow regular windows domain users to change their passwords through an .asp page? ...
1
by: Sankalp | last post by:
Hi, I am using VB 2005. My application has many data bound controls. The connection is stored in the app.config file. I want the application to start with a default connection string and while...
3
by: W C Hull | last post by:
We have a request from Auditing to modify the password an a local workstation administrative account every 90 days. We are developing two programs - a VB6 GUI program that will allow the...
1
by: eighthman11 | last post by:
Hi everyone: I created a custom toolbar called Password, so users can change their password. I used the Command "User and Group Accounts". I know the user can not change anything in the Tab...
0
by: shellegreen | last post by:
Hello, I need help with some password changes that I have to do in some iPAQs. The company that I work has 3 models of iPAQ and 3 different versions of Windows Mobile (Microsoft Pocket PC...
2
by: bemytthm | last post by:
I just want to ask abt communicate with AD using ASP.net. I would want to ask you all to help me correct a problem like this: This is a code i use to change password on AD public bool...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.