Different profiles on the same PC?

  • Thread starter Thread starter Bingo
  • Start date Start date
B

Bingo

How can I run different Apps on the same PC but using
different profiles in either Outlook Object or Mapi?
Thanks.
 
Bingo said:
How can I run different Apps on the same PC but using
different profiles in either Outlook Object or Mapi?
Thanks.

You can't in Outlook -- multiple instances of Outlook will always share
the same profile, it's a restriction of Outlook. Also, if there's an
existing session running (even if it's not an Outlook session) then
Outlook will join that session rather than starting its own one.

Depending on what you mean by "Mapi", the answer is different; Extended
MAPI, pass MAPI_NEW_SESSION and MAPI_EXPLICIT_SESSION in flFlags and pick
a session to use, just pass MAPI_NEW_SESSION to MAPILogon for simple mapi,
CDO1.21, set newSession=TRUE.

-- dan
 
Dan,

If I understand you correctly, I can start multiple
copies of the same App, each using a different Outlook
profile as long as I set newSession=TRUE in CDO1.21?
Thanks.
 
Bingo said:
If I understand you correctly, I can start multiple
copies of the same App, each using a different Outlook
profile as long as I set newSession=TRUE in CDO1.21?

That's correct -- you can even have multiple profiles in the same app:

Private Sub Form_Load()
Dim s1 As New MAPI.Session
s1.Logon newSession:=True, profileInfo:="server" & vbLf & "test1"
Debug.Print s1.Inbox.Messages.GetLast.Subject

Dim s2 As New MAPI.Session
s2.Logon newSession:=True, profileInfo:="server" & vbLf & "test2"
Debug.Print s2.Inbox.Messages.GetLast.Subject
End Sub

does what it looks like it'll do.

-- dan
 
Thanks a lot! This is exactly what I was looking for.
Thanks

One quick follow-up. I modified your code to test with
two others' profiles. I logged on the network as
myself. When the first session logon is called, a dialog
box pops up asking asking for the uid and password. Once
the logon is verified, the second session logon does not
pop up the dialog. I use two different profiles. Why
does this happen? Thanks.
 
Since the 2nd logon dialog does not show, I got the
following error when I tried to log on using the 2nd
profile.

[Collaboration Data Objects - [MAPI_E_LOGON_FAILED
(80040111)]]
 
Bingo said:
One quick follow-up. I modified your code to test with
two others' profiles. I logged on the network as
myself. When the first session logon is called, a dialog
box pops up asking asking for the uid and password. Once
the logon is verified, the second session logon does not
pop up the dialog. I use two different profiles. Why
does this happen? Thanks.

Ah, this stuff is only easy as long as all the mailboxes you're trying
to log in to are accessible to the currently logged in user. When that
changes, things get complicated..

I don't quite know why you're getting the login dialog, I don't see
that in my environment so there's something different in your setup, but
what's going on is that when you log in, that thread of execution is now
going to be authenticated as the person you first logged in as.

When you try and log in as the second person from the same thread,
there's two things that can happen -- either it can keep the thread
running as the first user you entered userid/pw for, in which case the
second person won't work -- or it could ask you to re-authenticate as
the second person, which would break the first person's login.

It looks like it's the former that's happening. There's no way around
this -- you can use the LogonUser/ImpersonateLoggedOnUser APIs to change
the login identity of a thread from code, but each thread can only be
one person at once.

I don't know how you'd do multiple threads in VB, sorry, you'd be
better off asking in one of the VB newsgroups for that (and I don't know
if the VB runtime will work nicely for that sort of thing, either, I
only know the basics there).

Alternative 2: you could run multiple instances of your app, one for
each person you need to be logged in as. Possibly the easiest solution.

Alternative 3: log in as some sort of administrator who can open
everyone's mailbox. Maybe easy, maybe not, depends on if you have the
power to do that sort of thing yourself. Where I work, I sure don't..

-- dan
 
Solution 2 would be the easiest for me. What I'm doing
is to run my app on the server to access a specific
mailbox on the exchange server. Since there are
different mailboxes for QA, training, production on the
same exchange server, multiple copies of this app will
run on the same server but to access different
mailboxes. Thanks!


-----Original Message-----


Ah, this stuff is only easy as long as all the mailboxes you're trying
to log in to are accessible to the currently logged in user. When that
changes, things get complicated..

I don't quite know why you're getting the login dialog, I don't see
that in my environment so there's something different in your setup, but
what's going on is that when you log in, that thread of execution is now
going to be authenticated as the person you first logged in as.

When you try and log in as the second person from the same thread,
there's two things that can happen -- either it can keep the thread
running as the first user you entered userid/pw for, in which case the
second person won't work -- or it could ask you to re- authenticate as
the second person, which would break the first person's login.

It looks like it's the former that's happening. There's no way around
this -- you can use the
LogonUser/ImpersonateLoggedOnUser APIs to change
 
Back
Top