code to add user to workgroup

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gluchu
    New Member
    • Feb 2007
    • 10

    code to add user to workgroup

    how to create a user from a form ???
    i looked in help and i find something like this :
    CREATE USER user password pid [, user password pid, …]
    but i don't get it
    how do the corect CREATE USER declaration looks ?

    can you help mi with that problem ?
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by gluchu
    how to create a user from a form ???
    i looked in help and i find something like this :
    CREATE USER user password pid [, user password pid, …]
    but i don't get it
    how do the corect CREATE USER declaration looks ?

    can you help mi with that problem ?
    To create a New User named John Doe with no Password, and to make him a member of the Admins Group:
    Code:
    Dim MyWks As Workspace, MyUser As User
    Set MyWks = DBEngine.Workspaces(0)
    
    With MyWks
      'Create and Append the New User John Doe
      Set MyUser = .CreateUser("John Doe")
        MyUser.PID = "B6TFRE45"     'Unique Identifier
        MyUser.Password = ""        'No Password
        .Users.Append MyUser
      'Make the User John Doe a member of the Admins Group by creating
      'and adding the User Object to the Admin's Group Users collection
      Set MyUser = .Groups("Admins").CreateUser("John Doe")
      .Groups("Admins").Users.Append MyUser
    End With

    Comment

    • gluchu
      New Member
      • Feb 2007
      • 10

      #3
      its working but when i try to login i get a message:
      Record(s) cannot be read; no read permission on "MySysAccessObj ects"
      ?????

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by gluchu
        its working but when i try to login i get a message:
        Record(s) cannot be read; no read permission on "MySysAccessObj ects"
        ?????
        I'm not really sure why you are getting this Error Message - perhaps it has something to do with restrictions applied to the Admins Group. I'll investigate further.

        Comment

        • gluchu
          New Member
          • Feb 2007
          • 10

          #5
          i add user to the new created group not to the admins group

          Comment

          • gluchu
            New Member
            • Feb 2007
            • 10

            #6
            i dont have permission to the system tables in security.mdw
            only the enginer have it

            Comment

            • gluchu
              New Member
              • Feb 2007
              • 10

              #7
              now i know why it dont works
              i had to add every created user to the users group
              Thnak's for your help ADezii

              Comment

              • gluchu
                New Member
                • Feb 2007
                • 10

                #8
                i need one more thing
                something in VB to change users password and to log out a user ?

                Comment

                • ADezii
                  Recognized Expert Expert
                  • Apr 2006
                  • 8834

                  #9
                  Originally posted by gluchu
                  i need one more thing
                  something in VB to change users password and to log out a user ?
                  Not VB but SQL:
                  Code:
                  ALTER USER <UserName> PASSWORD <NewPassword> <OldPassword>

                  Comment

                  Working...