472,961 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

Check if Exchange account exists from C# .Net application

I am writing an application that needs to check if an exchange account exists on a server. I am using C# and the .NET framework, so far there seems to be no way to do this. I believe we are using Exchange 2003 servers.
May 22 '07 #1
8 10836
Plater
7,872 Expert 4TB
Exchange is a Mail Server yes?
Attempt to establish a connection with the server and supply credentials. The server will respond with a message saying they are valid or invalid.

RFC2554
(Snip-it)
Expand|Select|Wrap|Line Numbers
  1. Examples:
  2.          S: 220 smtp.example.com ESMTP server ready
  3.          C: EHLO jgm.example.com
  4.          S: 250-smtp.example.com
  5.          S: 250 AUTH CRAM-MD5 DIGEST-MD5
  6.          C: AUTH FOOBAR
  7.          S: 504 Unrecognized authentication type.
  8.          C: AUTH CRAM-MD5
  9.          S: 334
  10.          PENCeUxFREJoU0NnbmhNWitOMjNGNndAZWx3b29kLmlubm9zb2Z0LmNvbT4=
  11.          C: ZnJlZCA5ZTk1YWVlMDljNDBhZjJiODRhMGMyYjNiYmFlNzg2ZQ==
  12.          S: 235 Authentication successful.
  13.  
If you supply an invalid credential some sort of 5xx error will be returned.
In theory atleast.
May 22 '07 #2
Exchange is a Mail Server yes?
Attempt to establish a connection with the server and supply credentials. The server will respond with a message saying they are valid or invalid.

RFC2554
(Snip-it)
Expand|Select|Wrap|Line Numbers
  1. Examples:
  2.          S: 220 smtp.example.com ESMTP server ready
  3.          C: EHLO jgm.example.com
  4.          S: 250-smtp.example.com
  5.          S: 250 AUTH CRAM-MD5 DIGEST-MD5
  6.          C: AUTH FOOBAR
  7.          S: 504 Unrecognized authentication type.
  8.          C: AUTH CRAM-MD5
  9.          S: 334
  10.          PENCeUxFREJoU0NnbmhNWitOMjNGNndAZWx3b29kLmlubm9zb2Z0LmNvbT4=
  11.          C: ZnJlZCA5ZTk1YWVlMDljNDBhZjJiODRhMGMyYjNiYmFlNzg2ZQ==
  12.          S: 235 Authentication successful.
  13.  
If you supply an invalid credential some sort of 5xx error will be returned.
In theory atleast.
This will work except, I will need to check for accounts other than my own, so therefore I would not have the password. I need to be able to do something like above and just get a simple exists/ or not feedback.
May 22 '07 #3
Frinavale
9,735 Expert Mod 8TB
This will work except, I will need to check for accounts other than my own, so therefore I would not have the password. I need to be able to do something like above and just get a simple exists/ or not feedback.
Does your program ask the user for their email address and password?
May 22 '07 #4
Plater
7,872 Expert 4TB
If you are lucky your exchange server will be the smart picky kind.
Then when you go to compsoe a fake email, you have to send it a list of recipients.
For example if your mail server controls @mydomain.com
You start a mock email and send it a RCPT TO with the email address.
If you send say Jones@mydomain.com it will look in it's own records for a Jones user.
Here is an exmple from the RFC pages on SMTP:
Expand|Select|Wrap|Line Numbers
  1. S: RCPT TO:<Jones@mydomain.com>
  2. R: 250 OK
  3.  
  4. S: RCPT TO:<Green@mydomain.com>
  5. R: 550 No such user here
  6.  
  7. S: RCPT TO:<Brown@mydomain.com>
  8. R: 250 OK
  9.  
  10. S: RCPT TO:<eric@mydomain.com>
  11. R: 552 Recipient storage full, try again in another transaction
  12.  
"550 No such user here" = user not on exchange server
"250 OK" = user exists

Be careful though, because you could get something like:
"552 Recipient storage full, try again in another transaction" which is an error, but the user still exists

EDIT:
Found this....
Expand|Select|Wrap|Line Numbers
  1. -------------------------------------------------------------
  2.  
  3.                     Example of Verifying a User Name
  4.  
  5.          Either
  6.  
  7.             S: VRFY Smith
  8.             R: 250 Fred Smith <Smith@mydomain.com>
  9.  
  10.          Or
  11.  
  12.             S: VRFY Smith
  13.             R: 251 User not local; will forward to <Smith@otherdomain.com>
  14.  
  15.          Or
  16.  
  17.             S: VRFY Jones
  18.             R: 550 String does not match anything.
  19.  
  20.          Or
  21.  
  22.             S: VRFY Jones
  23.             R: 551 User not local; please try <Jones@otherdomain.com>
  24.  
  25.          Or
  26.  
  27.             S: VRFY Gourzenkyinplatz
  28.             R: 553 User ambiguous.
  29.  
  30.                                Example 3
  31.  
  32.       -------------------------------------------------------------
  33.  
  34.  
May 22 '07 #5
Does your program ask the user for their email address and password?
no, I only get a user ID and thats it, I use this to look up some information, they some of the them have an additional exchange account and thats what I need to know. I'm kind of thinking of giving up on this since there seems to be no 'ez' way to interface the .net framework and ms exchange server.
May 23 '07 #6
Plater
7,872 Expert 4TB
The VRFY <username> command shoulda worked fine for you.

Building your own SMTP class would make you happy. (sarcasm hehe)
May 23 '07 #7
The VRFY <username> command shoulda worked fine for you.

Building your own SMTP class would make you happy. (sarcasm hehe)
haha, you'r right, I'm going to give that a try seems ez enought. I suppose I can use the System.Net classes to make do the request/response mechanics right?
May 23 '07 #8
Plater
7,872 Expert 4TB
System.Net.Sockets.TcpClient
If all you need to do is VRFY, it should be really easy

BEFORE you get too crazy with it, should should use like hyperterminal to see if your exchange server supports it.
I just checked on my mailserver (not an exchange server) and it went out of it's way to advertise that it supports VRFY/EXPN, but when I went to use them it just reported not supported. It's possible that I would need to AUTH myself before it worked, but converting my username/pass to base64 string in my head would be hard
May 23 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Manuel Krummenacher | last post by:
Hello! I'm trying to develop an application to manage email-forwardings on an Exchange 2000 Server. Forwardings to external Addresses are requiring a contact with an Exchange account. I can...
2
by: Vincent Nguyen | last post by:
Hi, I have problem create exchange 2000 mailbox using CDOEXM in my Web Service application. The error I got was "Catastrophic failure". Here is the code that I have: DirectoryEntry user =...
2
by: George Durzi | last post by:
We recently upgraded to Exchange2K3/W2K3 from Exchange2K/W2K, and some of my c# code that I used to access users' contacts using WebDAV has stopped working. I'm getting a 401 unauthorized error....
0
by: Mostro | last post by:
I have had an OMA problem for a month now, and cannot figure it out. A while back, can't rememeber a specific time, I was able to browse to my OMA at the local host using http://127.0.0.1/oma - it...
2
by: Joris De Groote | last post by:
Hi How can I check if a directory exists in a network drive? I can check it on the local machine, but when I want to check a network drive, that doenst work, how can I do this? Thanks Joris
0
by: Suman | last post by:
Hello Group, I am relatively new to .NET. I am trying to create a user in AD and a corresponding email account in the exchange server from an ASP.NET, C# application. ...
0
by: NissanSE98 | last post by:
Hello, I'm building an asp.net application that will get contact information from an Access Database that is linked to microsoft exchange or outlook. I go to link tables in Access and choose...
1
by: ouistyty | last post by:
Hi We have a simple asp page that query LDAP attribrute. Everithing is working fine using a native domain account. but when using an external account we have an error 70, acces denie. Here's...
5
by: Mufasa | last post by:
I've seen web sites that check to make sure an e-mail address is valid. How are they actually doing it? I'd like to integrate that into some code. TIA - Jeff.
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.