Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to set passwords to User Accounts

Status
Not open for further replies.

rl78

MIS
Sep 26, 2002
17
US
Hi All, I have set up a group in Access and have placed the individual user accounts into that group. Here's my issue: I want to assign the same password to all of these user accounts, is there a way that I could run some code to accomplish this instead of me signing onto access with each individual account and manually changing the password? thanks.

 
The below code (Access97) can be used to add users, and their passwords from code.....Let me know if you need more help

''''''''''''''''''''''''''''''''''''
' Start Code
''''''''''''''''''''''''''''''''''''

Dim UserName as Variant ' User Name
Dim UserPID as Variant ' Personal Id Number
Dim UserPW as Variant ' Password

UserName = ' Wherever you are getting the user name from
UserPID = ' Wherever you are getting the PID from
UserPW = ' Wherever you are getting the password from
DBEngine.SystemDB = ' Name of workgroup file

Set W = CreateWorkspace("TempLogin", "AdminEnabledAccount", "Password", dbUseJet)
Workspaces.Append W

Set New_User = W.CreateUser(UserName)
NewUser.PID = UserPID
New_User.Password = UserPW
W.Users.Append New_User

' Add User to Users Group
Set New_User = _
W.Groups("Users").CreateUser(UserName)
W.Groups("Users").Users.Append New_User

MsgBox "Successfully Added"

''''''''''''''''''''''''''''''''''
' End Code
'''''''''''''''''''''''''''''''''' If we knew what it was we were doing, it would not be called research, would it? - Albert Einstein [atom]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Thanks for your reply, however, I am very very new to VB coding and could use some help in narrowing down this code to do the following: What I need is to set the password to the user accounts that I have already created (whose default passwords are now blank). And not to create new user accounts in the process. Is there a way to assign the same password to all of these users who are in the same group? If so, what is the code for that? Please use the word "green" for the password in the code example so that I know where to enter it. Thanks for your help in this.
 
The following should allow you to update one password at a time....I haven't tested it, so let me know.

''''''''''''''''''''''''''''''''''''
' Start Code
''''''''''''''''''''''''''''''''''''
Public Sub UpdatePassword(strUserName As String, strWorkgroup As String)

DBEngine.SystemDB = strWorkgroup ' Name of workgroup file

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' In the next line, change AdminEnabled Account to an Account with Admin rights and Password to the
' password for that account
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set w = CreateWorkspace("TempLogin", "AdminEnabledAccount", "Password", dbUseJet)
Workspaces.Append w

Set User = w.Users(UserName)
User.Password = "Green"
w.Users.Refresh

MsgBox "Successfully Changed"

End Sub
''''''''''''''''''''''''''''''''''
' End Code
'''''''''''''''''''''''''''''''''' If we knew what it was we were doing, it would not be called research, would it? - Albert Einstein [atom]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Hello Again, here is what I have so far using the code you provided. The code compiles fine, however, I am not getting the succesfully created message from the MsgBox, so something is still wrong with the code. Please review and reply, thanks so much,
-----------
Public Sub UpdatePassword(strUserName As String, strWorkgroup As String)

DBEngine.SystemDB = strWorkgroup ' Name of workgroup file

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' In the next line, change AdminEnabled Account to an Account with Admin rights and Password to the
' password for that account
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set w = CreateWorkspace("TempLogin", "AdminEnabledAccount", "Password", dbUseJet)
Workspaces.Append w

Set User = w.Users(UserName)
User.Password = "Green"
w.Users.Refresh

MsgBox "Successfully Changed"

End Sub
''''''''''''''''''''''''''''''''''
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top