DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Setup database password

  1. #1
    Join Date
    Aug 2004

    Setup database password

    [Originally posted by Willy]

    how can i use vb6 to set and unset password for a ms access 2000 database??

  2. #2
    Join Date
    Aug 2004

    Re:Setup database password

    [Originally posted by m.posseth]

    you need ADOX ( go to references and select
    Microsoft ado ext for ddl and security )

    This example demonstrates the Append method of Groups, as well as the Append method of Users by adding a new Group and a new User to the system. The new Group is appended to the Groups collection of the new User. Consequently, the new User is added to the Group. Also, the ChangePassword method is used to specify the User password.

    ChangePassword Method
    Changes the password for a user account.

    User.ChangePassword OldPassword, NewPassword
    A String value that specifies the user's existing password. If the user doesn't currently have a password, use an empty string ("") for OldPassword.
    A String value that specifies the new password.
    For security reasons, the old password must be specified in addition to the new password.

    An error will occur if the provider does not support the administration of trustee properties.

    Sub GroupX()

    Dim cat As ADOX.Catalog
    Dim usrNew As ADOX.User
    Dim usrLoop As ADOX.User
    Dim grpLoop As ADOX.Group

    Set cat = New ADOX.Catalog
    cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=c:\Program Files\" & _
    "Microsoft Office\Office\Samples\Northwind.mdb;" & _
    "jet oledb:system database=c:\samples\system.mdb"

    With cat
    'Create and append new group with a string.
    .Groups.Append "Accounting"

    ' Create and append new user with an object.
    Set usrNew = New ADOX.User
    usrNew.Name = "Pat Smith"
    usrNew.ChangePassword "", "Password1"
    .Users.Append usrNew

    ' Make the user Pat Smith a member of the
    ' Accounting group by creating and adding the
    ' appropriate Group object to the user's Groups
    ' collection. The same is accomplished if a User
    ' object representing Pat Smith is created and
    ' appended to the Accounting group Users collection
    usrNew.Groups.Append "Accounting"

    ' Enumerate all User objects in the
    ' catalog's Users collection.
    For Each usrLoop In .Users
    Debug.Print " " & usrLoop.Name
    Debug.Print " Belongs to these groups:"
    ' Enumerate all Group objects in each User
    ' object's Groups collection.
    If usrLoop.Groups.Count <> 0 Then
    For Each grpLoop In usrLoop.Groups
    Debug.Print " " & grpLoop.Name
    Next grpLoop
    Debug.Print " [None]"
    End If
    Next usrLoop

    ' Enumerate all Group objects in the default
    ' workspace's Groups collection.
    For Each grpLoop In .Groups
    Debug.Print " " & grpLoop.Name
    Debug.Print " Has as its members:"
    ' Enumerate all User objects in each Group
    ' object's Users collection.
    If grpLoop.Users.Count <> 0 Then
    For Each usrLoop In grpLoop.Users
    Debug.Print " " & usrLoop.Name
    Next usrLoop
    Debug.Print " [None]"
    End If
    Next grpLoop

    ' Delete new User and Group objects because this
    ' is only a demonstration.
    .Users.Delete "Pat Smith"
    .Groups.Delete "Accounting"

    End With

    End Sub
    ' EndGroupVB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center