Search AD by Email

This code snippet allows you to search Active Directory for a given email address and
returns you the coresponding user object.  

String email = testUser@dev.lan; 

DirectoryEntry LdapConnection = new DirectoryEntry(); 
DirectorySearcher search = new DirectorySearcher(LdapConnection); 
search.SearchScope = SearchScope.Subtree; search.Filter = "(proxyaddresses=smtp:" + email + ")"; 
SearchResult result = search.FindOne();  

if
(result != null)
  { 
DirectoryEntry deDirEnt = result.GetDirectoryEntry();
  
Console.WriteLine("Address Found");
 
DirectoryEntry d = deDirEnt.SchemaEntry;
 
}
  else  { 
Console.WriteLine("Address not found!");
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

May 21. 2010 18:44

Designer handbags

You might even be able to get a free license if you are quick...

Designer handbags

August 14. 2010 16:58

mattew

You may have not intended to do so, but I think you have managed to express the state of mind that a lot of people are in. The sense of wanting to help, but not knowing how or where, is something a lot of us are going through.

mattew

August 17. 2010 13:13

vigrx

your site layout is very good

vigrx

August 26. 2010 23:23

Marilee Tyrance

great article. hope for the future of this blog is getting good with article more useful and good. ok thanks and god bless you

Marilee Tyrance

August 28. 2010 00:19

Pricilla Rollyson

Thanks a good deal! I truly enjoyed reading this.Looking through these posts and the information you've provided I can appreciate that I still have a lot of things to learn. I will keep reading and keep re-visiting

Pricilla Rollyson

August 29. 2010 08:27

Shalasha Hubs

Thanks for being honest.

Shalasha Hubs

August 30. 2010 22:12

increase semen volume

your site layout is very good

increase semen volume

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



 

Dilbert of the day