如何用SQL语句或C#代码对MSysObjects的设置管理权限
如何用SQL语句或C#代码对MSysObjects的设置管理权限?
请那些回答是 通过ACCESS-》安全-》用户与组权限 的朋友不要回复了
这种方法我也知道,但是我需要通过代码或SQL语句来设置对MSysObjects的设置管理权限?
改动是指在ACCESS中手动获取MsysObjects表的读取权限。
1. Open Microsoft Access
2. From the Tools menu, select the Options menu option
3. On the View tab, click the System Objects checkbox
4. Click OK to save your changes
5. From the Tools menu, select the Security -> User and Group Permissions menu option
6. Click the Permissions tab
7. Select the Table entry in the Object Type combo box
8. Select the Admin userid in the User/Group Name listbox
9. In the Object Name listbox, select the MSysObjects entry
10. In the Permissions group box, check the Read Data check box
这个好象与使用DAO和ADO访问关系不大啊,我在一个网站上发现下面一段程序但是看不大明白,高手能不能帮分析一下?
using the system.mdw file makes it easier to write programs that leave the database locked after the program exits.
The following modification to the demo seems to overcomes the “Record(s) cannot be read; no read permission on MSysObjects” problem without needing to change the security on the database though Access Menus.
use header #include "AFXDAO.H" to use the DAO functions and classes below
************************************************************************
In CAccessReportViewerDoc.cpp add function
void SetSystemDB( CString & strSystemMDB )
{
COleVariant varSystemDB( strSystemMDB, VT_BSTRT );
// Initialize DAO for MFC
AfxDaoInit( );
DAODBEngine* pDBEngine = AfxDaoGetEngine( );
ASSERT( pDBEngine != NULL );
// Call put_SystemDB method to set the
// system database for DAO engine
DAO_CHECK( pDBEngine->put_SystemDB( varSystemDB.bstrVal ) );
}
and modify function
BOOL CAccessReportViewerDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
//modify this to point to your system.mdw
CString strSystemDB =
_T( "C:\\Documents and Settings\\John\\Application Data\\Microsoft\\Access\\System.mdw" );
static bool bSetSystemDB=false;
if(bSetSystemDB==false)
{
SetSystemDB( strSystemDB );
bSetSystemDB=true;
}
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
m_pAccessReports = new CAccessReports(lpszPathName, TRUE);
return TRUE;
}
*********************************************************************************
In CAccessReportViewerDoc.cpp add and modify function
int CAccessReportViewerApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
//terminates the DAO database engine
AfxDaoTerm( );
return CWinApp::ExitInstance();
}
如果你已经有权限的情况下,你可以通 grant select on MSysObjects to username
VBA示例:
rt = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\ZZ\db\sjch.mdb;User ID=ylw;Password=lwgzsylw;Jet OLEDB:Database Password='';Jet OLEDB:System database=d:\ZZ\db\sjch.mdw"
QEE2.Groups("users").Users("ylw").SetPermissions "MsysObjects", adPermObjTable, adAccessSet, adRightNone
要以可以授权的用户登录,比如管理员
or
Dim QEE2 As New ADODB.Connection
rt = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\ZZ\db\sjch.mdb;User ID=ylw;Password=lwgzsylw;Jet OLEDB:Database Password='';Jet OLEDB:System database=d:\ZZ\db\sjch.mdw"
QEE2.Open rt
QEE2.Execute ("grant SELECT,DELETE,INSERT,UPDATE,DROP,CREATE,SELECTSCHEMA,SCHEMA,UPDATEOWNER,SELECTSECURITY,UPDATESECURITY on table MsysObjects to 用户名")