Accessing unmounted priv1.edb file using ESE API (Exchange Server 2003)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anup wadekar
    New Member
    • Jul 2009
    • 4

    Accessing unmounted priv1.edb file using ESE API (Exchange Server 2003)

    Hi,

    I am looking for mapping between the MailBox Table and its respective folders which are represented as Folder Table in the ESE database.

    As the MailBox table gives us the list of all the mailboxes stored in the EDB file which is basically unmounted. Through dumping the EDB file using the ESENTUTL.exe tool i got the list of all the folders and the mailboxes with the Index pages.

    Through this i am able to map the Folder tables like Inbox, Contacts etc with their parentIPM Store Table and their respective MailBox Table name.

    As i list the tables in the EDB file using the ESE API, i got all the tables but i dint found the MailBox table name which is basically an integer value (some what : 0001- 00000001798)

    But i am able to fetch and open the IPMStore Table and all the folders inside it. As the Folder Table names are also in the Integer type.

    Now i am looking to map these tables such that after fetching the MailBox table which stores all the list of mailboxes. After opening this table i am looking to get the Folder Table names by which i will be able to get the messages for the inbox, outbox, contacts etc folders of that particular mailbox.

    Is there any comman column in these table by which i can map the mail box table with thier related folder tables ?

    Kindly help me out, as i dint got any information regarding the Mapping of the Folder Tables and the mailbox table.

    Thanks in advance......
  • subbu123
    New Member
    • Aug 2009
    • 1

    #2
    Help please

    Hi Anup,

    I am trying to read a edb file using ESE APIs and am facing the problem of not
    being able to read any of the tables, here is my code, please tell me where i
    have gone wrong.

    /*************** *************** *************** *************** *************** **********/
    // One possible error-handling strategy is to jump to an error-handling
    // label whenever an ESENT call fails.
    #define Call(func) { \
    err = (func); \
    if(err < JET_errSuccess) { \
    goto HandleError; \
    } \
    }\
    {
    JET_ERR err = JET_bitNil;
    JET_INSTANCE instance = JET_bitNil;
    JET_SESID sesid = JET_bitNil;
    JET_DBID dbid = JET_bitNil;
    JET_TABLEID tableid = {1};

    JET_COLUMNDEF columndef = {0};
    JET_COLUMNID columnid = {0};

    Call(JetCreateI nstance2(&insta nce, "instance",NULL ,JET_bitNil));
    Call(JetInit(&i nstance));
    Call(JetBeginSe ssion(instance, &sesid, 0, 0));

    Call(JetAttachD atabase2(sesid, "tmp.edb",NULL, JET_bitDbReadOn ly ));

    char buffer[1024];
    Call(JetGetData baseInfo(sesid, dbid,buffer,siz eof(buffer),JET _DbInfoFilename ));
    MessageBoxA(NUL L,buffer,NULL,M B_OK);
    memset(buffer,N ULL,sizeof(buff er));

    Call(JetGetTabl eInfo(sesid,tab leid,buffer,siz eof(buffer),JET _TblInfoName));

    JetDetachDataba se(sesid,"tmp.e db");
    JetEndSession(s esid, 0);
    JetTerm(instanc e);
    return 0;

    HandleError:
    if(err == JET_errInvalidD atabase)
    {
    MessageBox(NULL ,_T("Invalid Database"),NULL ,MB_OK);
    }
    else
    {
    printf("ESENT error %d\n", err);
    }
    return 1;
    }
    /*************** *************** *************** *************** *************** **********/
    Regards
    Subramanya M.S

    Comment

    • anup wadekar
      New Member
      • Jul 2009
      • 4

      #3
      Try passing the table name as MsysObjects, which basically contains the name of all the tables.

      Comment

      • Mathi Das
        New Member
        • Aug 2010
        • 1

        #4
        Hi Anup,

        I'm trying to achieve the same task of reading mailbox from an unmounted exchange database using ese api. Unable to list the tables.

        Can you point out the error ?

        Here is my code,
        Code:
        #include "stdafx.h"
        #include <tchar.h>
        #include <windows.h>
        #undef JET_VERSION
        #define JET_VERSION 0x0501
        #include "esent.h"
        using namespace std;
        
        int _tmain(int argc, _TCHAR* argv[])
        {
        	cout<<"\nA sample project\n";
        	HINSTANCE LoadMe;
        	JET_INSTANCE instance;
        	JET_SESID sesid;
        	JET_PCSTR szFilename = "Mailbox Database.edb";
        	JET_ERR error;
        	JET_DBID dbid;
        	JET_RETRIEVECOLUMN retcol;
        	JET_COLUMNDEF coldef;
        	void *columnDef = &coldef;
        	void *pvResult = &retcol;
        	unsigned long cbMax = 2048;
        	JET_TABLEID tableid;
        	char buffer[2048];
        	char colBuffer[2048];
        	char retColBuf[2048];
        	unsigned long pcbActual;	
        
        
        	LoadMe = LoadLibrary("C:\\Program Files\\Microsoft\\Exchange Server\\Bin\\ese.dll");
        	if (LoadMe != 0)
        		cout<<"ese.dll library loaded!\n";
        	else
        		cout<<"ese.dll library failed to load!"<<GetLastError()<<"\n";
        
        	FUN_JET_SET_PARAM JetSetSystemParameters = NULL;
        	JetSetSystemParameters = (FUN_JET_SET_PARAM)GetProcAddress(LoadMe,"JetSetSystemParameter");
        	error = JetSetSystemParameters(&instance, JET_objtypTable,JET_paramDatabasePageSize, 8192, NULL);
        
        	FUN_ENTRY_POINT JetCreateInstances = NULL;
        	JetCreateInstances = (FUN_ENTRY_POINT)GetProcAddress(LoadMe,"JetCreateInstance");
        	error = JetCreateInstances(&instance,"databaseinstance");
        
        	FUN_JET_INIT JetInits = NULL;
        	JetInits = (FUN_JET_INIT)GetProcAddress(LoadMe,"JetInit");
        	error = JetInits(&instance);
        
        	FUN_JET_BEGIN_SESSION JetBeginSessions = NULL;
        	JetBeginSessions = (FUN_JET_BEGIN_SESSION)GetProcAddress(LoadMe,"JetBeginSession");
        	error = JetBeginSessions(instance,&sesid,NULL,NULL);
        
        	FUN_JET_ATTACH_DB JetAttachDatabases = NULL;
        	JetAttachDatabases = (FUN_JET_ATTACH_DB)GetProcAddress(LoadMe,"JetAttachDatabase");
        	error = JetAttachDatabases(sesid,szFilename, 0);
        
        	FUN_JET_OPEN_DB JetOpenDatabases = NULL;
        	JetOpenDatabases = (FUN_JET_OPEN_DB)GetProcAddress(LoadMe,"JetOpenDatabase");
        	error = JetOpenDatabases(sesid, szFilename, NULL, &dbid, JET_bitDbReadOnly);
        
        	FUN_JET_OPEN_TABLE JetOpenTables = NULL;
        	JetOpenTables = (FUN_JET_OPEN_TABLE)GetProcAddress(LoadMe,"JetOpenTable");
        	error = JetOpenTables(sesid,dbid,"MsysObjects",NULL,NULL,JET_bitTableReadOnly,&tableid);
        
        	FUN_JET_GET_TABLE_COL_INFO JetGetTableColumnInfos = NULL;
        	JetGetTableColumnInfos = (FUN_JET_GET_TABLE_COL_INFO)GetProcAddress(LoadMe,"JetGetTableColumnInfo");
        	error = JetGetTableColumnInfos(sesid,tableid,"Name",columnDef,2048,JET_ColInfo);
        	cout<<"\nJetGetTableColumnInfos = "<<error<<"\n";
        	coldef = (*((JET_COLUMNDEF *)(columnDef)));
        	cout<<"\nJetGetTableColumnInfos coldef.cbMax = "<<coldef.cbMax<<"\n";
        	cout<<"\nJetGetTableColumnInfos coldef.cbStruct = "<<coldef.cbStruct<<"\n";
        	cout<<"\nJetGetTableColumnInfos coldef.coltyp = "<<coldef.coltyp<<"\n";
        	cout<<"\nJetGetTableColumnInfos coldef.columnid = "<<coldef.columnid<<"\n";
        	cout<<"\nJetGetTableColumnInfos coldef.cp = "<<coldef.cp<<"\n";
        	cout<<"\nJetGetTableColumnInfos coldef.grbit = "<<coldef.grbit<<"\n";
        	cout<<"\nJetGetTableColumnInfos coldef.langid = "<<coldef.langid<<"\n";
        	cout<<"\nJetGetTableColumnInfos coldef.wCollate = "<<coldef.wCollate<<"\n";
        	cout<<"\nJetGetTableColumnInfos coldef.wCountry = "<<coldef.wCountry<<"\n";
        
        	FUN_JET_MOVE JetMoves = NULL;
        	JetMoves = (FUN_JET_MOVE)GetProcAddress(LoadMe,"JetMove");
        	error = JetMoves(sesid,tableid,JET_MoveFirst,0);
        	cout<<"\nJetMoves = "<<error<<"\n";
        
        	FUN_JET_RETRIEVE_COLUMNS JetRetrieveColumnss = NULL;
        	retcol.columnid = JET_COLUMNID(coldef.columnid);
        	unsigned long length = sizeof(retcol);
        	char pvData1[2048];
        	retcol.pvData = pvData1;
        	retcol.cbData = length;
        	retcol.grbit = 0;
        	retcol.itagSequence = 1;
        	JetRetrieveColumnss = (FUN_JET_RETRIEVE_COLUMNS)GetProcAddress(LoadMe,"JetRetrieveColumns");
        	error = JetRetrieveColumnss(sesid,tableid,&retcol,1);
        	cout<<"\nJetRetrieveColumnss = "<<error<<"\n";
        	cout<<"\nJetRetrieveColumnss  retcol.cbActual = "<<retcol.cbActual<<"\n";
        	cout<<"\nJetRetrieveColumnss  retcol.cbData = "<<retcol.cbData<<"\n";
        	cout<<"\nJetRetrieveColumnss  retcol.columnid = "<<retcol.columnid<<"\n";
        
        	
        	FUN_JET_CLOSE_TABLE JetCloseTables = NULL;
        	JetCloseTables = (FUN_JET_CLOSE_TABLE)GetProcAddress(LoadMe,"JetCloseTable");
        	error = JetCloseTables(sesid,tableid);
        
        	FUN_JET_CLOSE_DB JetCloseDatabases = NULL;
        	JetCloseDatabases = (FUN_JET_CLOSE_DB)GetProcAddress(LoadMe,"JetCloseDatabase");
        	error = JetCloseDatabases(sesid,dbid,0);
        
        	FUN_JET_DETACH_DB JetDetachDatabases = NULL;
        	JetDetachDatabases = (FUN_JET_DETACH_DB)GetProcAddress(LoadMe,"JetDetachDatabase");
        	error = JetDetachDatabases(sesid, szFilename);
        
        	FUN_JET_END_SESSION JetEndSessions = NULL;
        	JetEndSessions = (FUN_JET_END_SESSION)GetProcAddress(LoadMe,"JetEndSession");
        	error = JetEndSessions(sesid,0);
        
        	FUN_JET_TERM JetTerms = NULL;
        	JetTerms = (FUN_JET_TERM)GetProcAddress(LoadMe,"JetTerm");
        	error = JetTerms(instance);
        
        
        	if(FreeLibrary(LoadMe))
        		cout<<"library unloaded\n";
        	else
        		cout<<"library unload failed"<<GetLastError()<<"\n";
        	return 0;
        }
        Thanks
        Mathi

        Comment

        Working...