473,698 Members | 2,450 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MAPI Logon fails (NT Service)

Hi All,

I'm having problems with ex MAPI when its running from an NT service.

This is the code i'm running in the log on process.

Please... if you can see ANY problem, let me know....

void Logon(System::S tring* profile)

{

HRESULT hRes = -1;

LPVOID pMapiInit;

LPTSTR pprof;

FLAGS ntServiceMAPIFi eld = MAPI_NT_SERVICE ;

FLAGS mapiInitField = MAPI_NO_COINIT | MAPI_MULTITHREA D_NOTIFICATIONS ;

FLAGS mapiLogonFlags = MAPI_NEW_SESSIO N | MAPI_NO_MAIL | MAPI_EXTENDED |
MAPI_EXPLICIT_P ROFILE ;//| MAPI_PASSWORD_U I;

////////////////////////////////////////////////////////

// ***Important: Only if this module is a Service unmark the next 2 line.

mapiInitField |= ntServiceMAPIFi eld;

mapiLogonFlags |= ntServiceMAPIFi eld;

////////////////////////////////////////////////////////
MAPIINIT_0 MAPIINIT = { MAPI_INIT_VERSI ON, mapiInitField};

pMapiInit = &MAPIINIT;

if (FAILED(hRes = MAPIInitialize( pMapiInit)))

{

Marshal::ThrowE xceptionForHR(h Res);

}

pprof = (char*)Marshal: :StringToHGloba lAnsi(profile). ToPointer();

LPMAPISESSION __pin* pses = &m_pSes;

if (FAILED(hRes = MAPILogonEx((UL ONG)0, pprof, NULL, mapiLogonFlags, pses)))

{

Marshal::FreeHG lobal(pprof);

Marshal::ThrowE xceptionForHR(h Res);

}

m_pDefMsgStore = NULL;

Marshal::FreeHG lobal(pprof);

}

Regards,

Asaf
Nov 16 '05 #1
1 3401
Michael,

What account is the service running under? By default, I believe that
the account runs over the LOCALSYSTEM (or LOCALSERVICE, I can't remember the
name) account. This account doesn't have access to the netowkr, so you
would have to have the service run under an account which does have access
to the network.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Michael Zino" <mv****@mercury .co.il.RemoveMe > wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi All,

I'm having problems with ex MAPI when its running from an NT service.

This is the code i'm running in the log on process.

Please... if you can see ANY problem, let me know....

void Logon(System::S tring* profile)

{

HRESULT hRes = -1;

LPVOID pMapiInit;

LPTSTR pprof;

FLAGS ntServiceMAPIFi eld = MAPI_NT_SERVICE ;

FLAGS mapiInitField = MAPI_NO_COINIT | MAPI_MULTITHREA D_NOTIFICATIONS ;

FLAGS mapiLogonFlags = MAPI_NEW_SESSIO N | MAPI_NO_MAIL | MAPI_EXTENDED |
MAPI_EXPLICIT_P ROFILE ;//| MAPI_PASSWORD_U I;

////////////////////////////////////////////////////////

// ***Important: Only if this module is a Service unmark the next 2 line.

mapiInitField |= ntServiceMAPIFi eld;

mapiLogonFlags |= ntServiceMAPIFi eld;

////////////////////////////////////////////////////////
MAPIINIT_0 MAPIINIT = { MAPI_INIT_VERSI ON, mapiInitField};

pMapiInit = &MAPIINIT;

if (FAILED(hRes = MAPIInitialize( pMapiInit)))

{

Marshal::ThrowE xceptionForHR(h Res);

}

pprof = (char*)Marshal: :StringToHGloba lAnsi(profile). ToPointer();

LPMAPISESSION __pin* pses = &m_pSes;

if (FAILED(hRes = MAPILogonEx((UL ONG)0, pprof, NULL, mapiLogonFlags, pses)))
{

Marshal::FreeHG lobal(pprof);

Marshal::ThrowE xceptionForHR(h Res);

}

m_pDefMsgStore = NULL;

Marshal::FreeHG lobal(pprof);

}

Regards,

Asaf

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4944
by: Suganthi | last post by:
Hi, I have a specific problem while using MAPI for sending the emails from my application. My requirement is as follows. My application will be running either as a service or a process in a windows 2000/NT server. For a given user (who is Windows NT user) in the same Windows 2000
0
1407
by: Mukesh Kumar | last post by:
hi all, I have created some independent reports through crystal reports developer edition v 10 and developed a small tool in .net framework v 1.1 to view these reports through the crystal reports viewer provided by .net. This is a stand-alone windows application and nothing to do with the server. I am using local SQL anywhere database and connection is via an ODBC DSN. Before launching the reports I am passing the login information to...
0
485
by: Peter Steele | last post by:
I want to create a local admin account programmatically and set it so that it to have "Logon as Service" rights and not be able to be logged on interactively. How are these extended rights configured?
0
911
by: web1110 | last post by:
Hi y'all, I there a way for a service to be notified when a user logs on. Also, is there a way to initiate a system service so it will be the last service to run. Thanx, Bill
0
1251
by: Sid | last post by:
hi all, i'm using mapi in my application and create a mapi session using MAPILogonEx passing it the profile name (that is created dynamically by my program). Now from a windows NT/2k machine when i access the inbox of the person logged into the machine everthing works fine as i'm able to get the mails but when i want to access some other mailbox's mails. i get an error. could someone help me here? it is important to access any mailbox without...
0
2183
by: PhilHip | last post by:
I've written a Windows service in VB.Net that accesses the global address list to obtain all the entries to store them in a local database. The GAL is accessed using the MS Exchange profile on the current machine. The service then creates a new MAPI session and then attempts to log on to the session using the current MS Exchange profile on the machine. Here is the section of code that is erroring: Dim oSession As MAPI.Session...
9
5447
by: Tim Baley | last post by:
I recently created some intranet web sevices to expose stored procedures on our SQL Servers (SQL2k). The stored procedures include an audit trail with user/login identification, so the web services are set up for Windows integrated authentication. The web sevices work well when they are hosted on IIS on my Win2k Pro development machine. I have tried accessing the services under several user accounts on several machines, including...
6
21309
by: Manuel | last post by:
Hi, Using the PIA "Microsoft Outlook 11 Object Library". I've noticed that the Logon method of the NameSpace Object is simply ignored. My Outlook 2003 is full updated. For example if I write: Dim oApp As New Outlook.Application
1
1691
by: WayneClements | last post by:
Does anyone know why a simple select like : SELECT SettingValue FROM sysCONFIG_SETTINGS WHERE ModuleName = N'ScheduledTask' AND SettingKey = N'Logon' should fail in oracle 10g It fails with 'no such column' It works is I use N'Logonxxx' or 'Logon' And it works in SQL+ and SQL/Developer
0
8675
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8862
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7729
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6521
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.