Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Tue, 8 Jul 2008 13:19:00 -0700,    group: microsoft.public.win32.programmer.messaging        back       


Avoid MAPI Authentication Dialogs   
1. CredUI on calling IMsgServiceAdmin::ConfigureMsgService when creating a 
profile, I have the username and password, is there a way to avoid this 
dialog?

2. CredUI on calling IMAPISession::OpenMsgStore with store type set to 
"\x54\x94\xA1\xC0\x29\x7F\x10\x1B\xA5\x87\x08\x00\x2B\x2A\x25\x17", I am 
using the profile just created to get back the IMAPISession, is there a way 
to avoid this dialog?

Thanks.
date: Tue, 8 Jul 2008 13:19:00 -0700   author:   jwu

Re: Avoid MAPI Authentication Dialogs   
Hi jwu,

> 1. CredUI on calling IMsgServiceAdmin::ConfigureMsgService when
> creating a profile, I have the username and password, is there a way
> to avoid this dialog?

Run your application in a user account with full access to the mailbox
you connect to.

> 2. CredUI on calling IMAPISession::OpenMsgStore with store type set to
> "\x54\x94\xA1\xC0\x29\x7F\x10\x1B\xA5\x87\x08\x00\x2B\x2A\x25\x17", I
> am using the profile just created to get back the IMAPISession, is
> there a way to avoid this dialog?

Same as 1)

--
SvenC
date: Tue, 8 Jul 2008 23:12:06 +0200   author:   SvenC am

Re: Avoid MAPI Authentication Dialogs   
I thought about that, but running the application process under mailbox user 
account is not an option.

"SvenC" wrote:

> Hi jwu,
> 
> > 1. CredUI on calling IMsgServiceAdmin::ConfigureMsgService when
> > creating a profile, I have the username and password, is there a way
> > to avoid this dialog?
> 
> Run your application in a user account with full access to the mailbox
> you connect to.
> 
> > 2. CredUI on calling IMAPISession::OpenMsgStore with store type set to
> > "\x54\x94\xA1\xC0\x29\x7F\x10\x1B\xA5\x87\x08\x00\x2B\x2A\x25\x17", I
> > am using the profile just created to get back the IMAPISession, is
> > there a way to avoid this dialog?
> 
> Same as 1)
> 
> --
> SvenC
>
date: Tue, 8 Jul 2008 14:23:06 -0700   author:   jwu

Re: Avoid MAPI Authentication Dialogs   
Then you are out of luck. Why is it not an option? You can always connect to 
one mailbox, then opeen other mailboxes (if you have sufficient rights) 
using IExchangeManageServer.
What exactlty are you trying to do with that mailbox?

-- 
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-
"jwu"  wrote in message 
news:91EDAD77-94F1-46FF-A388-E8B46F33210E@microsoft.com...
>I thought about that, but running the application process under mailbox 
>user
> account is not an option.
>
> "SvenC" wrote:
>
>> Hi jwu,
>>
>> > 1. CredUI on calling IMsgServiceAdmin::ConfigureMsgService when
>> > creating a profile, I have the username and password, is there a way
>> > to avoid this dialog?
>>
>> Run your application in a user account with full access to the mailbox
>> you connect to.
>>
>> > 2. CredUI on calling IMAPISession::OpenMsgStore with store type set to
>> > "\x54\x94\xA1\xC0\x29\x7F\x10\x1B\xA5\x87\x08\x00\x2B\x2A\x25\x17", I
>> > am using the profile just created to get back the IMAPISession, is
>> > there a way to avoid this dialog?
>>
>> Same as 1)
>>
>> --
>> SvenC
>>
date: Tue, 8 Jul 2008 15:39:37 -0700   author:   Dmitry Streblechenko

Re: Avoid MAPI Authentication Dialogs   
On 8 jul, 22:19, jwu  wrote:
> 1. CredUI on calling IMsgServiceAdmin::ConfigureMsgService when creating a
> profile, I have the username and password, is there a way to avoid this
> dialog?
>
> 2. CredUI on calling IMAPISession::OpenMsgStore with store type set to
> "\x54\x94\xA1\xC0\x29\x7F\x10\x1B\xA5\x87\x08\x00\x2B\x2A\x25\x17", I am
> using the profile just created to get back the IMAPISession, is there a way
> to avoid this dialog?
>
> Thanks.

Hi jwu,

I'm using this code to create a profile (code is not mine, but can't
remember where I got it). It works perfectly, without asking anything.
It's in Delphi, but you'll easily translate it to C++.

function TProfileCreator.CreateProfileAndLogOn(const
ProfileName,UserName,
    ServerName:PChar): bool;
var
hr:HRESULT;
ulFlags:ULONG;
lppProfAdmin:IPROFADMIN;
lpServiceAdmin:IMsgServiceAdmin;
lppTable:IMAPITABLE;
pRows:PSRowSet;
lpProp : PSPropValueArray;
I:byte;
MsgStoreUID :PMAPIUID;
lppMAPIError:pMAPIError;
MAPIINIT:TMAPIINIT;
label cleanup;

begin
  pRows:=nil;

  ulFlags := MAPI_NEW_SESSION or
        MAPI_EXTENDED or
        MAPI_NO_MAIL or    // We will not send or receive mails
        MAPI_NT_SERVICE or  //
        MAPI_BEST_ACCESS;

  MapiInit.ulVersion := MAPI_INIT_VERSION;
  MapiInit.ulFlags := MAPI_NT_SERVICE;

  hr:=mapiInitialize(@MAPIINIT);

  if failed(hr) then
  LogMessage('mapiInitialize HR: '+IntToStr(HR));

  MAPIINITOK:=hr=S_OK;

  szProfileName:=ProfileName;
  {
   GetMem(szProfileName,MAX_PATH+1);

  // Create a unique profile name

  hr:=HrCreateProfileName('Test', MAX_PATH, szProfileName);

  if failed(hr) then
  LogMessage('HrCreateProfileName HR: '+IntToStr(HR))  ;
  else
  LogMessage('HrCreateProfileName : '+szProfileName,
  EVENTLOG_INFORMATION_TYPE);  }

  if MAPIINITOK then
   begin

  // Get pointer to administration object - IPROFADMIN interface

  hr:=MAPIAdminProfiles(0,lppProfAdmin);
  if failed(hr) then
  begin
    LogMessage('MAPIAdminProfiles HR: '+IntToStr(HR));
    goto Cleanup;
  end;

  // We first try to delete profile (if exist)
  lppProfAdmin.DeleteProfile(szProfileName, 0); //HR CAN BE<>S_OK  !!!

  //Creates a new MAPI profile for service
  hr:=lppProfAdmin.CreateProfile(szProfileName, nil, 0, 0);
  if failed(hr) then
  begin
    LogMessage('lppProfAdmin.CreateProfile HR: '+IntToStr(HR));
    goto cleanup;
  end;

  hr:=lppProfAdmin.AdminServices(szProfileName,nil,
0,0,lpServiceAdmin);
  if failed(hr) then
  begin
    LogMessage('lppProfAdmin.AdminServices HR: '+IntToStr(HR));
    goto cleanup;
  end;

  hr:=lpServiceAdmin.CreateMsgService('MSEMS','MS Exchange',0,0);
  if failed(hr) then
  begin
    LogMessage('lpServiceAdmin.CreateMsgService HR: '+IntToStr(HR));
    goto cleanup;
  end;

  hr:=lpServiceAdmin.GetMsgServiceTable(0,lppTable);

  if(FAILED(hr))  then
  begin
    LogMessage('lpServiceAdmin.GetMsgServiceTable HR: '+IntToStr(HR));
    goto cleanup;
  end;

  hr:=lppTable.QueryRows(1,0,pRows);
  if(FAILED(hr))  then
  begin
    LogMessage('lppTable.QueryRows HR: '+IntToStr(HR));
    goto cleanup;
  end;

  for I:=0 to pRows.aRow[0].cValues-1 do
   if (pRows.aRow[0].lpProps[I].ulPropTag = PR_SERVICE_UID) then
    begin
      MsgStoreUID := PMAPIUID(pRows.aRow[0].lpProps[I].Value.bin.lpb);
      break;
    end;
    I:=0;



  MAPIAllocateBuffer(sizeof(TSPropValueArray)
+sizeof(TSPropValue)*2,Pointer(lpProp));

  MAPIAllocateMore(StrLen(UserName)
+1,Pointer(lpProp),Pointer(lpProp[0].Value.lpszA));

  MAPIAllocateMore(StrLen(ServerName)
+1,Pointer(lpProp),Pointer(lpProp[I+1].Value.lpszA));

  MAPIAllocateMore(StrLen(UserName)+1,Pointer(lpProp),Pointer(lpProp[I
+2].Value.lpszA));

    lpProp[0].ulPropTag := PR_PROFILE_UNRESOLVED_NAME;
    StrCopy(lpProp[0].Value.lpszA,UserName);

    lpProp[I+1].ulPropTag := PR_PROFILE_UNRESOLVED_SERVER;
    StrCopy(lpProp[I+1].Value.lpszA,ServerName);

    lpProp[I+2].ulPropTag := PR_PROFILE_MAILBOX;
    StrCopy(lpProp[I+2].Value.lpszA,UserName);


    hr:=lpServiceAdmin.ConfigureMsgService(
      MsgStoreUID,
      0, 0,3, PSPropValue(lpProp));
    if(FAILED(hr))  then
    begin .....


  cleanup:
  if assigned(pRows) then FreePRows(pRows);
  lppTable:=nil;
  if assigned(lppMAPIError) then lppMAPIError:=nil;
  lpServiceAdmin:=nil;
  lppProfAdmin:=nil;
  Result:=hr=S_OK;
date: Wed, 9 Jul 2008 03:00:05 -0700 (PDT)   author:   patochem

Re: Avoid MAPI Authentication Dialogs   
On 8 jul, 23:23, jwu  wrote:
> I thought about that, but running the application process under mailbox user
> account is not an option.
>
> "SvenC" wrote:
> > Hi jwu,
>
> > > 1. CredUI on calling IMsgServiceAdmin::ConfigureMsgService when
> > > creating a profile, I have the username and password, is there a way
> > > to avoid this dialog?
>
> > Run your application in a user account with full access to the mailbox
> > you connect to.
>
> > > 2. CredUI on calling IMAPISession::OpenMsgStore with store type set to
> > > "\x54\x94\xA1\xC0\x29\x7F\x10\x1B\xA5\x87\x08\x00\x2B\x2A\x25\x17", I
> > > am using the profile just created to get back the IMAPISession, is
> > > there a way to avoid this dialog?
>
> > Same as 1)
>
> > --
> > SvenC

Jwu,

Here is the Delphi snipet I use to create profiles. In my case, it
doesn't ask for any credentials. The code is not mind, and I can't
remember from who I took it.
Hope it can helps.

function TProfileCreator.CreateProfileAndLogOn(const
ProfileName,UserName,
    ServerName:PChar): bool;
var
hr:HRESULT;
ulFlags:ULONG;
lppProfAdmin:IPROFADMIN;
lpServiceAdmin:IMsgServiceAdmin;
lppTable:IMAPITABLE;
pRows:PSRowSet;
lpProp : PSPropValueArray;
I:byte;
MsgStoreUID :PMAPIUID;
lppMAPIError:pMAPIError;
label cleanup;

begin
  szProfileName:=ProfileName;

  if MAPIINITOK then   // Mapi initialization routine here as
MAPI_NT_SERVICE
   begin

  // Get pointer to administration object - IPROFADMIN interface

  hr:=MAPIAdminProfiles(0,lppProfAdmin);
  if failed(hr) then
  begin
    LogMessage('MAPIAdminProfiles HR: '+IntToStr(HR));
    goto Cleanup;
  end;

  // We first try to delete profile (if exist)
  lppProfAdmin.DeleteProfile(szProfileName, 0); //HR CAN BE<>S_OK  !!!

  //Creates a new MAPI profile for service
  hr:=lppProfAdmin.CreateProfile(szProfileName, nil, 0, 0);
  if failed(hr) then
  begin
    LogMessage('lppProfAdmin.CreateProfile HR: '+IntToStr(HR));
    goto cleanup;
  end;

  hr:=lppProfAdmin.AdminServices(szProfileName,nil,
0,0,lpServiceAdmin);
  if failed(hr) then
  begin
    LogMessage('lppProfAdmin.AdminServices HR: '+IntToStr(HR));
    goto cleanup;
  end;

  hr:=lpServiceAdmin.CreateMsgService('MSEMS','MS Exchange',0,0);
  if failed(hr) then
  begin
    LogMessage('lpServiceAdmin.CreateMsgService HR: '+IntToStr(HR));
    goto cleanup;
  end;

  hr:=lpServiceAdmin.GetMsgServiceTable(0,lppTable);

  if(FAILED(hr))  then
  begin
    LogMessage('lpServiceAdmin.GetMsgServiceTable HR: '+IntToStr(HR));
    goto cleanup;
  end;

  hr:=lppTable.QueryRows(1,0,pRows);
  if(FAILED(hr))  then
  begin
    LogMessage('lppTable.QueryRows HR: '+IntToStr(HR));
    goto cleanup;
  end;

  for I:=0 to pRows.aRow[0].cValues-1 do
   if (pRows.aRow[0].lpProps[I].ulPropTag = PR_SERVICE_UID) then
    begin
      MsgStoreUID := PMAPIUID(pRows.aRow[0].lpProps[I].Value.bin.lpb);
      break;
    end;
    I:=0;



  MAPIAllocateBuffer(sizeof(TSPropValueArray)
+sizeof(TSPropValue)*2,Pointer(lpProp));

  MAPIAllocateMore(StrLen(UserName)
+1,Pointer(lpProp),Pointer(lpProp[0].Value.lpszA));

  MAPIAllocateMore(StrLen(ServerName)
+1,Pointer(lpProp),Pointer(lpProp[I+1].Value.lpszA));

  MAPIAllocateMore(StrLen(UserName)+1,Pointer(lpProp),Pointer(lpProp[I
+2].Value.lpszA));

    lpProp[0].ulPropTag := PR_PROFILE_UNRESOLVED_NAME;
    StrCopy(lpProp[0].Value.lpszA,UserName);

    lpProp[I+1].ulPropTag := PR_PROFILE_UNRESOLVED_SERVER;
    StrCopy(lpProp[I+1].Value.lpszA,ServerName);

    lpProp[I+2].ulPropTag := PR_PROFILE_MAILBOX;
    StrCopy(lpProp[I+2].Value.lpszA,UserName);


    hr:=lpServiceAdmin.ConfigureMsgService(
      MsgStoreUID,
      0, 0,3, PSPropValue(lpProp));
    if(FAILED(hr))  then
    begin
     lppMAPIError:=nil;
     lpServiceAdmin.GetLastError(hr,0,lppMAPIError);
     if assigned(lppMAPIError) then
        if assigned(lppMAPIError.lpszError) then
           LogMessage(lppMAPIError.lpszError) else
                LogMessage('lpServiceAdmin.ConfigureMsgService Error')
     else LogMessage('lpServiceAdmin.ConfigureMsgService Error');
       goto cleanup;
    end;

        FMapiSession:=nil;
        hr:=MAPILogonEx(0, szProfileName, nil,
            ulFlags,
      MapiX.IMAPISession(FMapiSession));

  if(FAILED(hr))  then begin
    LogMessage('Error MAPILogonEx HR: '+IntToStr(HR));
   goto cleanup;
  end;

  end;

  cleanup:
  if assigned(pRows) then FreePRows(pRows);
  lppTable:=nil;
  if assigned(lppMAPIError) then lppMAPIError:=nil;
  lpServiceAdmin:=nil;
  lppProfAdmin:=nil;
  Result:=hr=S_OK;
end;

PS: Sorry if double post (it looked like my first one didn't get
through)
date: Wed, 9 Jul 2008 03:32:57 -0700 (PDT)   author:   patochem

Re: Avoid MAPI Authentication Dialogs   
Hi patochem,

> I'm using this code to create a profile (code is not mine, but can't
> remember where I got it). It works perfectly, without asking anything.
> It's in Delphi, but you'll easily translate it to C++.

Your app is running in a user account which has full access to
the mailbox, right? Then of course you do not get a logon dialog.

Run your code with a local, not domain account on your machine
and see that you will get a logon dialog.

--
SvenC
date: Wed, 9 Jul 2008 13:54:03 +0200   author:   SvenC am

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us