Problem changing password using ADOX.Catalog.Users(User).ChangePassword

  • Thread starter Thread starter Neil Robbins
  • Start date Start date
N

Neil Robbins

I have written a VB.NET 2003 application to front-end a MS Access DB. I want
to build into this the ability for users to change their passwords. I have
written some code for users to be able to do this based on code taken from
Rick Dobson's 'Programming Microsoft Access 2000'. This code is also
available form 'ms-help://MS.VSCC/MS.MSDNVS/dnacc2k/html/acchap2.htm'. When
I run this code I get an error message that says:
'System.Runtime.InteropServices.COMException (0x800A0CB3): Object or
provider is not capable of performing requested operation. at
ADOX.Users.get_Item(Object Item). This seems strange to me as I have used
the exact same code previously in another application fronting another MS
Access DB using workgroup information files created using the Access
security wizard for the specific db. Both applications run using the latest
version of MDAC (2.8) with the correct references. This makes me think that
the problem may lie with the Access DB. The connection strings in both
applications are identical as is all of the other code. I have cut and paste
the code pertaining to the connection below. I also use an
OleDb.OleDbConnection (cnn1) to access the data held in the database and
this all works fine.

Public cnn2 As New ADODB.Connection
cnn2.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Jet
OLEDB:SystemDatabase=" & systemdblocation & ";Data Source=" & examdblocation
& ";UserID=" & User & ";Password=" & PWord)

I have also read at this location
'ms-help://MS.MSDNQTR.2003FEB.1033/ado270/htm/adoddlm1_9.htm' that 'An error
will occur if the provider does not support the administration of trustee
properties.'

Could this be the problem that I am encountering? How could I ensure that
the provider (is this Jet, the DB I created in Access or something else)
does support the administration of trustee properties?

Any help or information is always much appreciated.
 
Hello Neil,

Thanks for posting in our community.

From your description, I'm not 100% sure if the issue is related to Access
DB. When you performed the sample code to build into the ability for your
users to change their passwords, you receoved teh following error message:

'System.Runtime.InteropServices.COMException (0x800A0CB3): Object or
provider is not capable of performing requested operation

However, the same thing didn't happen in another application. Have I fully
understand you? If there is anything I misunderstood, please feel free to
let me know.

Based on my experience, the issue may be caused by the permission of the
MDW file. Please try to use ADO (not ADOX) method to connect and update
the database. If it is only a problem when you use ADOX to write a change
to a user object at this one site, I suspect that the the MDW file might
have a file permission of read-only. Please verify this and I also wonder
if the databae is shared on the network drive.




In the meanwhile, would you please try to following method to build the
password changing ability for your users. If the problem persists, please
collect the detailed informaion for my inside analysis. Thanks in advance!

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''
'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.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''

' BeginGroupVB
Sub Main()
On Error GoTo GroupXError

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:\Program Files\Microsoft Office\Office\system.mdw'"

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
Else
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
Else
Debug.Print " [None]"
End If
Next grpLoop

' Delete new User and Group objects because this
' is only a demonstration.
' These two line are commented out because the sub "OwnersX" uses
' the group "Accounting".
' .Users.Delete "Pat Smith"
' .Groups.Delete "Accounting"

End With

'Clean up
Set cat.ActiveConnection = Nothing
Set cat = Nothing
Set usrNew = Nothing
Exit Sub

GroupXError:

Set cat = Nothing
Set usrNew = Nothing

If Err <> 0 Then
MsgBox Err.Source & "-->" & Err.Description, , "Error"
End If
End Sub
' EndGroupVB

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''

Neil, please apply my suggestions above and let me know if this helps
resolve your problem. If there is anything more I can do to assist you,
please don't hesitate to tell me. All our efforts will make things clearer
and move closer to the causes and resolutions.


Thank you,

Billy Yao
Microsoft Online Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hello Billy,

Thanks for getting back to this posting. I have tried to answer some of your
questions in the text of your response below. I hope that this way of
responding is not too annoying.

Any further help gladly accepted!!

Neil.


"Billy Yao [MSFT]" said:
Hello Neil,

Thanks for posting in our community.

From your description, I'm not 100% sure if the issue is related to Access
DB. When you performed the sample code to build into the ability for your
users to change their passwords, you receoved teh following error message:

'System.Runtime.InteropServices.COMException (0x800A0CB3): Object or
provider is not capable of performing requested operation

However, the same thing didn't happen in another application. Have I fully
understand you? If there is anything I misunderstood, please feel free to
let me know.

This is correct, although the other application accesses another secured
access database.
Based on my experience, the issue may be caused by the permission of the
MDW file. Please try to use ADO (not ADOX) method to connect and update
the database.
I use ADO.NET methods to do anything with the database except changing user
details (eg; password, groups belonged to etc...). If there are ways of
doing these things using ADO rather than ADOX I should be very glad to find
out how.
If it is only a problem when you use ADOX to write a change
to a user object at this one site, I suspect that the the MDW file might
have a file permission of read-only. Please verify this and I also wonder
if the databae is shared on the network drive.

I have checked both the mdw and mdb files and neither are read-only. The
database for the application that has the required functionality working
correctly is used currently on a network drive. When developing though I had
the database on the same computer that I developed the application on. This
is the same situation that I find myself in with my new 'problem'
application. Both it and the database it is designed to work with are on the
same computer.
In the meanwhile, would you please try to following method to build the
password changing ability for your users. If the problem persists, please
collect the detailed informaion for my inside analysis. Thanks in advance!

I have tried this code (both as is and altered) already, I found it at
'ms-help://MSDNQTR.2003FEB.1033/ado270/htm/adoddlx1_14.htm'. It produces the
exact same error.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''
'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.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''

' BeginGroupVB
Sub Main()
On Error GoTo GroupXError

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:\Program Files\Microsoft Office\Office\system.mdw'"

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
Else
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
Else
Debug.Print " [None]"
End If
Next grpLoop

' Delete new User and Group objects because this
' is only a demonstration.
' These two line are commented out because the sub "OwnersX" uses
' the group "Accounting".
' .Users.Delete "Pat Smith"
' .Groups.Delete "Accounting"

End With

'Clean up
Set cat.ActiveConnection = Nothing
Set cat = Nothing
Set usrNew = Nothing
Exit Sub

GroupXError:

Set cat = Nothing
Set usrNew = Nothing

If Err <> 0 Then
MsgBox Err.Source & "-->" & Err.Description, , "Error"
End If
End Sub
' EndGroupVB

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''

Neil, please apply my suggestions above and let me know if this helps
resolve your problem. If there is anything more I can do to assist you,
please don't hesitate to tell me. All our efforts will make things clearer
and move closer to the causes and resolutions.

I hope so... I'm at a complete loss and any help would be very much
appreciated.
 
Hi Neil,

From your description, I understand that you cannot set the password for
the Access .mdb file using ADOX. However, the error message doesn't quite
make sense. As far as I know, the Jet engine should be capable of this
method.

Could you paste your code that changes the password here? It might be more
helpful for us to reproduce the problem, so that we can deliver our
assistance more quickly. Thank you for your cooperation!

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Kevin,

I couldn't agree more this doesn't make any sense to me at all. I have cut
and pasted the code below. Cnn2 is an ADO connection. I have used this exact
same code in another application for use with another Access DB and it has
worked fine.

Thanks for taking an interest in my problem, any help is gratefully
received.

Neil

Dim pwform As New ChPWordDialog

pwform.lblTitle.Text += User

Me.AddOwnedForm(pwform)

If pwform.ShowDialog() = DialogResult.OK Then

If pwform.txtCurrent.Text <> PWord Then

MsgBox("The current password that you supplied is incorrect.")

Else

If pwform.txtNew.Text <> pwform.txtNew2.Text Then

MsgBox("The two entries of the new password did not match.")

Else

Try

Try

cnn2.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:System
Database=" & systemdblocation & ";Data Source=" & examdblocation & ";User
ID=" & User & ";Password=" & PWord)

cnn2.Open()

Catch exc As Exception

MsgBox(exc.ToString)

End Try

Dim cat1 As New ADOX.Catalog

cat1.ActiveConnection = cnn2

cat1.Users(User).ChangePassword(pwform.txtCurrent.Text, pwform.txtNew.Text)

MsgBox("The password has been changed successfully.")

'MsgBox("Was " & PWord & ". Now " & pwform.txtNew.Text)

PWord = pwform.txtNew.Text

Catch exc As Exception

MsgBox("The change of password failed for technical reasons." & vbCr & "If
this persists then please contact the manufacturer for advice." & vbCr &
exc.ToString)

Finally

cnn2.Close()

End Try

End If

End If

Else

'Cancel was pressed.

End If
 
Hi Neil,

I've checked the code and it works perfect on my machine. It seems that the
problem relates with the interop for ADODB COM object. In .NET, if we are
working on managed code and need to use ADO (As ADO is unmanaged COM
object), we have to use the PIA (Primary Interop Assembly) of ADODB. It
means when adding reference, we have to use the adodb on the .NET tab in
Add reference dialog box.

For more information about PIA, please check the following link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/whypriinterop.asp

If that still cannot resolved the problem, I think there might be something
wrong with the installation of MDAC package. Please try to download and
re-install it at the following link:

http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-
b037-185d0506396c&DisplayLang=en

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Thanks Kevin,

I have run though and put responses to your advice in the body of your
posting below.

As I say any further assistance will be much appreciated.

Regards,

Neil Robbins.

Kevin Yu said:
Hi Neil,

I've checked the code and it works perfect on my machine.

It works perfectly on mine just not in this one application.
It seems that the problem relates with the interop for ADODB COM object. In ..NET, if we are
working on managed code and need to use ADO (As ADO is unmanaged COM
object), we have to use the PIA (Primary Interop Assembly) of ADODB. It
means when adding reference, we have to use the adodb on the .NET tab in
Add reference dialog box.

Tried this now to no effect
For more information about PIA, please check the following link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/whypriinterop.asp

If that still cannot resolved the problem, I think there might be something
wrong with the installation of MDAC package. Please try to download and
re-install it at the following link:

http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-
b037-185d0506396c&DisplayLang=en

Have reinstalled it from the latest (March 2004) MSDN offering (2426.5)
again with no joy, presumably my having used this rather than the
downloadable copy will not have made a difference
If anything is unclear, please feel free to reply to the post.

Just what to do, I am at a complete loss as to what to do. Any futher help
much needed and much appreciated!
 
Hi Neil,

If problem still persists, maybe you can send me the project that could
reproduce the problem? Remove 'online' from this no spam email is my real
email address. Thank you for your cooperation.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
On Thu, 26 Feb 2004 10:53:04 GMT, (e-mail address removed) (Kevin Yu [MSFT]) wrote:

¤ Hi Neil,
¤
¤ If problem still persists, maybe you can send me the project that could
¤ reproduce the problem? Remove 'online' from this no spam email is my real
¤ email address. Thank you for your cooperation.

Hi Kevin,

I've been looking at this same issue and am seeing the same error as Neil. Doesn't matter whether it
is operating within VB.NET or Visual Basic 6.0.

As a matter of fact I attempted to reference the Count property of the Users collection in the Debug
window (of VB 6.0) and am generating the 3251 error (Object or provider is not capable of performing
the requested operation).


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Hi Kevin,

Sorry to have taken so long to get the files to you. Something strange
happened when I was preparing the stuff to send you. I created a new project
to send to you, added the references to it cut and paste the necessary bits
of code, made a copy of my db and stripped out the current tables and put a
dummy one in. I then pressed F5 and expected it to fail. It didn't it
worked!! I have no idea why though :-( I guess I might try starting a new
solution and just inserting the necessary files and then try adding the
references again, maybe somthing is just lying around and lousing up the
ADOX object. Any suggestions still much appreciated and if you wanted the
full non-working project and db to check through I would be happy to provide
you with it. I hope though that I may have got a solution for now.

Thanks for all the help,

Neil
 
Hi Neil,

Please feel free to send me the full non-working package if it is not quite
too big. :)

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Kevin,

sorry to have taken so long to reply to this posting, I've had a couple of
days of work. I have sent the solution to the email address that you had
suggested in your earlier email. Thanks for all the help.

Neil.
 
Hi again Kevin,

Unfortunately the email bounced - outlook suggests it is either too big or
your mailbox is full, the email is about 14.4MB.

Any suggestions?

Neil
 
Hi Neil,

It seems that our exchanges server does not allow such big attachments.

This issue seems to be very strange and needs further troubleshooting.
Since the code that changes the password is correct while the full package
doesn't work, generally, we have to check carefully that if the connection
to the database files is good, and if the .mdb and .mdw file is being used
by other connections.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Kevin,

I have responded in the body of the text of your email below. Thanks again
for the continued interest in this problem.

Neil.

Kevin Yu said:
Hi Neil,

It seems that our exchanges server does not allow such big attachments.

What is the largest permissable size, I might be able to strip out elements
of the solution in order to make it smaller.
This issue seems to be very strange and needs further troubleshooting.
Since the code that changes the password is correct while the full package
doesn't work, generally, we have to check carefully that if the connection
to the database files is good, and if the .mdb and .mdw file is being used
by other connections.

I'm fairly certain that the .mdb and .mdw files are not being used by other
connections as these files are only being used by my 'problem' solution, and
that is only on my development PC, and only used by me. Whether other
routines in the solution are leaving the connection open after they have
finished I doubt as I have been fastidiously checking for this and ensuring
that cnn.close is applied.

Whether the connection to the database files is good I do not know, and I
don't know how to check.
 
Hi Neil,

The quota of a single mail in my mailbox is 4MB. Please try to make the
package smaller. Please also check if the problem only occurs on your
computer. If you copy the solution and the database to another computer,
can the job run properly?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Kevin,

I'll do what you suggest, but it will probably have to be on Tuesday due to
other pressures.

Thanks again for your continued interest in this problem.

Neil R.
 
Hi Kevin,

Sorry for the delay, I should get what you suggest done by the end of this
weekend.

Regards,

Neil
 
Hi Neil,

I will be waiting for your repro package. Please also include the .mdw file
in the package.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top