Getting E-Mail-Adress of User in a Web Service

S

Stefan Falk

Hello everybody,

the following code gets the e-mail address of an Active Directory account
when run inside a simple windows forms app:

Dim Query As String = "(SAMAccountName=TheAccountName)"
Dim Searcher As DirectorySearcher = New DirectorySearcher(Query, New
String() {"mail"})
Dim Result As SearchResult = Searcher.FindOne

However, running this inside an asp.net web service while impersonating the
calling user, which is logged on fine in active directory, Result is
nothing. Why?

Thanks in advance for a tip,
Stefan Falk
 
C

Chris S

I went through many exercises querying Active Directory using impersonation,
where it works with the default credentials, does not work with supplied
credentials, works with supplied credentials on the same machine as the WEB
service, etc, etc.
I ended up creating a DirectoryEntry object with a user name and password
(special user name and password created only to query Active Directory) as
parameters and construct the DirectorySearcher with the DirectoryEntry as
parameter. This is the only way I could get it to work consistent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top