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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADOX and Adding Users

Status
Not open for further replies.

JeffCarlin

Programmer
Aug 16, 2001
33
0
0
US
This code is taken straight from MSDN. However, when it tries to execute the Append method into an Access XP database, I get "Err 3251, Object or provider is not capable of performing requested operation.":
Code:
    Dim cat As ADOX.Catalog
    Dim usrNew As ADOX.User
    
    Set cat = New ADOX.Catalog
    cat.ActiveConnection = "Provider=MICROSOFT.JET.OLEDB.4.0;" _
                & "Jet OLEDB:System database=mySystem.mdw;" _
                & "User ID=admin;" _
                & "Password=admin;" _
                & "Persist Security Info=True;" _
                & "Data Source=myDB.mdb"
    
    With cat
       
        ' Create and append new user with an object.
        Set usrNew = New ADOX.User
        usrNew.Name = "PatSmith"
        usrNew.ChangePassword "", "password1"
        .Users.Append usrNew

    End With
Anyone have an idea??
 
Jeff,

I have had the same problem (see thread181-350699) and I still haven't been able to resolve it. (I get the error if I don't log in as Admins). I am wondering whether you ever found a reason/solution to the problem?

Thanks,
tgikristi
 
Try this

first open the database as an Admins member

Mike

Public Function iADOXAddNewUser(sNewUserName As String, sPassword As String) As Integer

Dim cat As ADOX.Catalog


' anticipate failure if user already exists
iADOXAddNewUser = -1

On Error GoTo ExitError

DBPROVIDER = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DB.mdb & ";"
SYSTEMPROVIDER = "Jet OLEDB:System Database=" & DB.mdw & ";"
DBSECURITY = "Persist Security Info=false;User Id=" & sAdminUser & ";"

Set cat = New ADOX.Catalog

cat.ActiveConnection = DBPROVIDER & SYSTEMPROVIDER & DBSECURITY

With cat

.Users.Append sNewUserName, sPassword

End With

iADOXAddNewUser = 1 ' add user succeeded

Set cat = Nothing

Exit Function

ExitError:

MsgBox &quot;ERROR: Username could not be added <&quot; & sNewUserName & &quot;, &quot; & sPassword & &quot;>&quot;, vbExclamation, &quot;ADOX - Add New User&quot;

Set cat = Nothing

End Function
When you call out for help in the darkness, and you hear a voice in return, you're probably just talking to yourself again!
 
Thanks,

I will try this right now--sorry I hadn't noticed a reply and just re-posted so I apologize to everyone for being so pesty!

Thanks,
tgikristi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top