Solved

Mapi logon User domain and pass

Posted on 2002-05-21
46
789 Views
Last Modified: 2008-03-03
   How would i set a mapi control to logon using the user name, domain, and password? My issue is that i supplied the user name and passowrd, but it is not logging in. When i try to check the mail it tells me the login failed. The login sub that i have created, creates no errors, and even assigns a session id. I dont know if this is really the issue or not.
0
Comment
Question by:damion69
  • 15
  • 12
  • 9
  • +6
46 Comments
 
LVL 2

Expert Comment

by:vbDoc
ID: 7025007
Hi,
Using MAPI is a two step process. 1. Open a session. 2. Do mail stuff using the Session ID.

As long as you get a session Id then you are ready to go.

Don't forget to close the session when done.

HTH,
vbDoc
0
 
LVL 4

Expert Comment

by:gencross
ID: 7025193
Here is an example of the mapi session and message object:

    With frmEMail.mapSession
        ' Set DownLoadMail to False to prevent immediate download.
        .DownLoadMail = False
        .LogonUI = True ' Use the underlying email system's logon UI.
        .SignOn ' Signon method.
        .NewSession = True
        'blnNewSession = .NewSession
        frmEMail.mapMessage.SessionID = .SessionID ' You must set this before continuing.
    End With


    With frmEMail.mapMessage
        .Compose
        .RecipIndex = 0
        .RecipDisplayName = "[SMTP:" & sEMailAddress & "]"
        '.RecipType = mapToList
       
        If sCCEMail <> "" Then
            .RecipType = mapCcList
            .RecipIndex = 1
            .RecipDisplayName = "[SMTP:" & sCCEMail & "]"
        End If
       
        .MsgSubject = sSubject
       
        strFile = Dir(PDFInvoicePath & "\*.*")
       
        'Get the count of file attachments
        Do While strFile <> ""
            iPosition = iPosition + 1
            strFile = Dir
        Loop
       
        .MsgNoteText = Space(iPosition + 1) & sBody '& "         "              'this seems to be required
               
        .Send
     end with
0
 
LVL 4

Expert Comment

by:gencross
ID: 7025241
I hope this makes sense.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7025500
hearing...
0
 
LVL 2

Author Comment

by:damion69
ID: 7027440
That is how i have my code. When i logon, i am not using the LogonUI = True, i have it set to false, and it seems to logon. I get a session id which is a number, but every time i try to read or even compose mail, i get an error that the logon information is incorrect. When i do use the interface, it allows me to enter a domain name with the logon. Then it works. The issue with not using the logon, is if there are probles with the box it is going on, and we have to reboot, i need the program to automaticly start.
0
 
LVL 3

Expert Comment

by:MCummings111400
ID: 7028431
What do you have the UserName property of the MAPISession control set to? And Does the currently logged on user have access to the mailbox you are trying to open?
0
 
LVL 2

Author Comment

by:damion69
ID: 7029765
The username is the profile name. the currently logged user is me, so yes i have access to my mailbox.
0
 
LVL 2

Author Comment

by:damion69
ID: 7039514
Anyone going to comment, Can this be done?? If not please delete and refund my points
0
 
LVL 3

Expert Comment

by:MCummings111400
ID: 7039552
In the profile you are using, what services are you configured for?
0
 
LVL 2

Author Comment

by:damion69
ID: 7040008
microsoft exchange. When i log into my mail, i go through outlook, and it requires me to enter username password, and domain. Then it logs me in. I need to know how to simulate this through pure mapi and not using the outlook objects.
0
 
LVL 3

Expert Comment

by:MCummings111400
ID: 7040759
Ok, I think that is your problem. Your profile is configured for user supplied authentication (Username , Password) if you set the UI to false, it can't ask you for that information, and hence your errors. I'm going to take a look to see if there is a way around this. I'll try to have an answer back by tommorrow.
0
 
LVL 2

Author Comment

by:damion69
ID: 7042126
I am loking for a way to have the program login automaticly. I do not want the user to have to type anything in. So through code somehow i need to pass user, pass, and domain.
0
 
LVL 3

Expert Comment

by:MCummings111400
ID: 7042190
Is it an IT requirement that the user supply their username and password agin to log onto the mail server? You can set the profile to use the current logged on user to authenticate and bypass that second dialog for logging into the mail server.
0
 
LVL 2

Author Comment

by:damion69
ID: 7042464
This application is not going to be ran by users. This is a Server/Client excel report scheduler. the server must be able to log into the mail without user input. So i store that in an ini file, encrypted using rc4 encryption. So the information will be entered for this on setup. so now i can pass the user and pass without a problem. I just cant get it to work due to the requirement of enterine a domain, like i would have to do to enter my mail. i enter the user pass and domain as would the server also. once the server logs on to the mail, then users are allowed to connect to it.
0
 
LVL 3

Expert Comment

by:MCummings111400
ID: 7053961
Ok, done my reseaching. As far as I can tell, in order to get the Session to authenticate without user input, you MUST allow the currently logged on user access to the mailbox specified in the profile and set the LOGONUI = false. This will allow the application to connect to the exchnage server using the credentials of whomever is logged into the console (or the user specified in the service properties if you are running the app as a service)

If you are forcing users to enter their DOMAIN/USERNAME and PASSWORD then you must use LogonUI = True. Hovever since you want no user intervention, you will have to allow the logged on user access to the mailbox.

If you can supply me with some more details about your Exchange configuration I might be able to give you a more explicit example.
0
 
LVL 2

Author Comment

by:damion69
ID: 7056231
I do not control how exchange is set up. I have my box, and even after i login to the network, i still am required to enter user,pass, and domain to access my mail.
0
 
LVL 2

Author Comment

by:damion69
ID: 7067707
How do i close this question?
0
 
LVL 2

Author Comment

by:damion69
ID: 7092428
The answer needed was not given. I am still reserching to figure out how to resolve this issue.
0
 

Expert Comment

by:Gathanas
ID: 7147119
Try having your app map a drive to a share with the un/dom. or open an IPC pipe to the PDC or BDC with the un/pw.  I hear that once you authenticate that way you can pass that token to the exch. server and login to the other mailbox.  Alternatively, you can use NT scheduler and have it login automatically with the un/pw and run your app.  you would then be able to open a session and run your app.

Good Luck!
George
0
 
LVL 2

Author Comment

by:damion69
ID: 7154244
This still does not work. I have to supply the Domain also. I need to know how to enter the domain with the user name and pass.
0
 

Expert Comment

by:fokkerlit
ID: 7267646
I have the same problem. I cant get the domain name entered into the logon function. Everything works when I have the logon window pop up, but otherwise i get errors, if you found a resolution to this i would love to know it.
0
 
LVL 2

Author Comment

by:damion69
ID: 7267693
I am still trying to find a resolution to this. I dont really think there is one. But then how does outlook do it. I have the same issue trying to use the outlook item.
0
 

Expert Comment

by:fokkerlit
ID: 7267970
Someone mentioned using the sendkeys function, but it doesnt seem to work, when the code runs it pauses and doesnt like anything else run. With the Senkeys method you could just have it automatically go through that dialogue box. Right now I'm trying to find a function that will log me into the domain somehow. Hopefully that will work.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Expert Comment

by:fokkerlit
ID: 7267975
Someone mentioned using the sendkeys function, but it doesnt seem to work, when the code runs it pauses and doesnt like anything else run. With the Senkeys method you could just have it automatically go through that dialogue box. Right now I'm trying to find a function that will log me into the domain somehow. Hopefully that will work.
0
 

Expert Comment

by:fokkerlit
ID: 7267983
Someone mentioned using the sendkeys function, but it doesnt seem to work, when the code runs it pauses and doesnt like anything else run. With the Senkeys method you could just have it automatically go through that dialogue box. Right now I'm trying to find a function that will log me into the domain somehow. Hopefully that will work.
0
 

Expert Comment

by:fokkerlit
ID: 7267991
Someone mentioned using the sendkeys function, but it doesnt seem to work, when the code runs it pauses and doesnt like anything else run. With the Senkeys method you could just have it automatically go through that dialogue box. Right now I'm trying to find a function that will log me into the domain somehow. Hopefully that will work.
0
 

Expert Comment

by:fokkerlit
ID: 7268001
Someone mentioned using the sendkeys function, but it doesnt seem to work, when the code runs it pauses and doesnt like anything else run. With the Senkeys method you could just have it automatically go through that dialogue box. Right now I'm trying to find a function that will log me into the domain somehow. Hopefully that will work.
0
 

Expert Comment

by:fokkerlit
ID: 7268023
Someone mentioned using the sendkeys function, but it doesnt seem to work, when the code runs it pauses and doesnt like anything else run. With the Senkeys method you could just have it automatically go through that dialogue box. Right now I'm trying to find a function that will log me into the domain somehow. Hopefully that will work.
0
 

Expert Comment

by:fokkerlit
ID: 7268027
Someone mentioned using the sendkeys function, but it doesnt seem to work, when the code runs it pauses and doesnt like anything else run. With the Senkeys method you could just have it automatically go through that dialogue box. Right now I'm trying to find a function that will log me into the domain somehow. Hopefully that will work.
0
 

Expert Comment

by:fokkerlit
ID: 7268078
Someone mentioned using the sendkeys function, but it doesnt seem to work, when the code runs it pauses and doesnt like anything else run. With the Senkeys method you could just have it automatically go through that dialogue box. Right now I'm trying to find a function that will log me into the domain somehow. Hopefully that will work.
0
 

Expert Comment

by:fokkerlit
ID: 7268090
Someone mentioned using the sendkeys function, but it doesnt seem to work, when the code runs it pauses and doesnt like anything else run. With the Senkeys method you could just have it automatically go through that dialogue box. Right now I'm trying to find a function that will log me into the domain somehow. Hopefully that will work.
0
 

Expert Comment

by:fokkerlit
ID: 7268106
Someone mentioned using the sendkeys function, but it doesnt seem to work, when the code runs it pauses and doesnt like anything else run. With the Senkeys method you could just have it automatically go through that dialogue box. Right now I'm trying to find a function that will log me into the domain somehow. Hopefully that will work.
0
 
LVL 3

Expert Comment

by:MCummings111400
ID: 7268111
The answer is this;

You can NOT use a MAPI/Outlook profile that has the Logon Network Security set to None. (Control Panel-> Mail; Select 'Microsoft Exchange Server'; Click Properties; Select the Advanced Tab; It's down at the bottom)

AND Set LogonUI = False!

By setting LogonUI = False you are telling MAPI NOT do allow any Dialog Boxes to be displayed, But you are requireing the user to supply the credentials in the Profile.

If you require no user intervention, then you MUST set the
Logon Network Security to NT Password Authentication. Additionally the currently logged on User Account (Which includes the DOMAIN) MUST have User permissions to the Mailbox. (If you currently supply a different domain/Username/Password to gain access to your mailbox than what you use to logon to your workstation then this is not the case)





0
 

Expert Comment

by:Gathanas
ID: 7268124
You can access your mailbox by using the code below.  One condition must be met.  The currently logged on user (Im assuming you are using NT Security Married to Exchange) must have access to the mailbox you are trying to access.  To fully automate the processing run this on an NT server with the scheduling tool and provide the NT logon and password of the id that has access to the mailbox your process is trying to access.  I've done this and it works.

-George


   Dim sExchServer             As String
    Dim sExchUser               As String
    Dim sProfileInfo            As String
    Dim sess                    As MAPI.Session
    Dim sInbox                  As Object

    sExchServer = "Your Exchange Server Name Here"
    sExchUser = "Your MailBox Alias Here"
    'Your Currently logged on account needs to have access to the mailbox
    'This assumes NT Security on both login and exchange


    sProfileInfo = sExchServer + vbLf + sExchUser

    Set sess = New MAPI.Session
    'setting up a session

    sess.Logon , , False, True, 0, , sProfileInfo

    ' Check for a valid logon.
    Set sInbox = sess.Inbox
0
 
LVL 2

Author Comment

by:damion69
ID: 7272344
Gathanas, This is telling me nothing more than i already know. as said before i do not have control or access to the exchange box. I can not change permissions ect.



MCummings, NT Password Authentication is what i ahve to set it to inorder for me to even be able to connect. I still can not do this without user inervention.
0
 

Expert Comment

by:Gathanas
ID: 7273064
You do not need access to the Exchange Box, you need access to the NT Server.  Via the scheduler service you can have the application run with "MCummings" rights and then when the code runs it will login as that person.  What do you see when you step through the code?  Can you post the code you are using to logon (minus confidential info)?
0
 
LVL 3

Expert Comment

by:MCummings111400
ID: 7273386
Couple of quick questions;
 What version of Outlook/MAPI is installed?
 What version of Exchnage are you trying to connect to?
 Is the Exchange Server in the same domain?
 If not is it in a trusting Domain?
0
 
LVL 2

Author Comment

by:damion69
ID: 7274557
I am using Outlook 2000, but i am not using that as the control, i am using pure mapi. The exchange server is 2000 and it is on a seperate domain, and not trusted. That is why i must enter in the domain, username, and pass to log on to the system.
0
 
LVL 3

Expert Comment

by:MCummings111400
ID: 7274709
Ok, one last question before I try something out;

Are your username and passwords the same between the 2 domains?
0
 

Expert Comment

by:fokkerlit
ID: 7275008
I know that my usernames are the same but my passwords are different. I tried looking into Redemption.Dll, but it didnt seem to offer any assistance. I noticed people on Microsoft news groups had similar problems, but there was no real resolution there either. There were a few hundred pages of articles, i havent finished going through them as of yet, but i dont know what i will find.
0
 
LVL 3

Expert Comment

by:MCummings111400
ID: 7276032
Try changing the passwords so that they match, this will allow the exchange server to authenticate without any intervention. See if it stops the dialog from displaying. You can test it with Outlook too, it should not prompt you for a set of credentials to get access to your mailbox.
0
 
LVL 2

Author Comment

by:damion69
ID: 7276979
I found the solution on microsotfs web site, there is not a way to pass it in code...

http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q288775&
0
 
LVL 2

Author Comment

by:damion69
ID: 7360526
Please PAQ the resolution was made by myself that this can not be done.
0
 

Expert Comment

by:Gathanas
ID: 7389468
Thats not true.  I have done this and explained it above.
0
 
LVL 16

Expert Comment

by:twalgrave
ID: 7896441
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- PAQ'd and points refunded
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

twalgrave
Cleanup Volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7941752
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now