|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
HOW Change PasswordI 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! 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 Even if you do not have an active directory server, you can still change a> Directory. > I need to do it from an application created with VB2005. 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(); Work perfect for which it needed...
Thank you very much Mehdi !!! Show quoteHide quote "Mehdi" <vio***@REMOVEME.gmail.com> escribió en el mensaje news:1wipmq2xf96ga$.10wtyqz1j4pin.dlg@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(); 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 Show quoteHide quote "Xnet" wrote: > Work perfect for which it needed... > > Thank you very much Mehdi !!! > > > "Mehdi" <vio***@REMOVEME.gmail.com> escribió en el mensaje > news:1wipmq2xf96ga$.10wtyqz1j4pin.dlg@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(); > > >
Password Protect
Write to an XML file using data from an SQLserver table DataBinding with Unbound Columns and calling EndCurrentEdit ListBox Problem XML WebSvc Proxy Code Syntax Questions Limit ComboBox entry to ipaddress format firing a dts package's execution How To Show Partial Classes as a Hierarchy in Solution Explorer? Passing a parameter Collection Using .NET user controls into VB6 |
|||||||||||||||||||||||