ANR and LDAP queries

  • Thread starter Thread starter Matthew Kaess
  • Start date Start date
M

Matthew Kaess

We are running a custom application which requests the
users mail property in AD for there email address. The
developers are using the DOMAIN\username syntax to query
AD for this information. The problem is it appears to be
using some soft of Ambiguous Name Resolution because it's
returning the wrong email address. Example;

The app is asking AD for the mail property of
sAMAccountName DOMAIN\matthew. The message is being sent
to user Cheryl Matthews instead. Any thoughts on what may
be occuring or how the developers can rewrite their code
to return the correct address? Thanx in advance!

Matthew Kaess
 
the sAMAccountName should only be matthew not DOMAIN\matthew. They should
be binding using ldap://domain and using a ldap filter of
(&(objectclass=user)(sAMAccountName=matthew))

tx
 
I have the piece of code that's supposed to do this -
Dim root As New System.DirectoryServices.DirectoryEntry
("LDAP://" & Domain)

Dim rootSearch As New
System.DirectoryServices.DirectorySearcher(root)
rootSearch.Filter = "samaccountname=" & UserName
Dim sResult As System.DirectoryServices.SearchResult =
rootSearch.FindOne
Try
Return sResult.Properties(PropertyName).Item(0)

Catch
Return "Property Not Found"
End Try


-----Original Message-----
the sAMAccountName should only be matthew not DOMAIN\matthew. They should
be binding using ldap://domain and using a ldap filter of
(&(objectclass=user)(sAMAccountName=matthew))

tx

--
Jeromy Statia [MSFT]

This posting is provided "AS IS" with no warranties, and confers no rights.


We are running a custom application which requests the
users mail property in AD for there email address. The
developers are using the DOMAIN\username syntax to query
AD for this information. The problem is it appears to be
using some soft of Ambiguous Name Resolution because it's
returning the wrong email address. Example;

The app is asking AD for the mail property of
sAMAccountName DOMAIN\matthew. The message is being sent
to user Cheryl Matthews instead. Any thoughts on what may
be occuring or how the developers can rewrite their code
to return the correct address? Thanx in advance!

Matthew Kaess


.
 
the filter is incorrect.. try setting the rootSearch.Filter =
"(&(objectclass=user)(sAMAccountName=" & UserName & "))"

tx

--
Jeromy Statia [MSFT]

This posting is provided "AS IS" with no warranties, and confers no rights.


Matthew Kaess said:
I have the piece of code that's supposed to do this -
Dim root As New System.DirectoryServices.DirectoryEntry
("LDAP://" & Domain)

Dim rootSearch As New
System.DirectoryServices.DirectorySearcher(root)
rootSearch.Filter = "samaccountname=" & UserName
Dim sResult As System.DirectoryServices.SearchResult =
rootSearch.FindOne
Try
Return sResult.Properties(PropertyName).Item(0)

Catch
Return "Property Not Found"
End Try


-----Original Message-----
the sAMAccountName should only be matthew not DOMAIN\matthew. They should
be binding using ldap://domain and using a ldap filter of
(&(objectclass=user)(sAMAccountName=matthew))

tx

--
Jeromy Statia [MSFT]

This posting is provided "AS IS" with no warranties, and confers no rights.


We are running a custom application which requests the
users mail property in AD for there email address. The
developers are using the DOMAIN\username syntax to query
AD for this information. The problem is it appears to be
using some soft of Ambiguous Name Resolution because it's
returning the wrong email address. Example;

The app is asking AD for the mail property of
sAMAccountName DOMAIN\matthew. The message is being sent
to user Cheryl Matthews instead. Any thoughts on what may
be occuring or how the developers can rewrite their code
to return the correct address? Thanx in advance!

Matthew Kaess


.
 
This filter is ok because sAMAccountName is indexed. If that was some other
non-indexed value you would also want to throw in (objectcategory=person) or
the search would degrade horribly.

--
www.joeware.net


Jeromy Statia said:
the filter is incorrect.. try setting the rootSearch.Filter =
"(&(objectclass=user)(sAMAccountName=" & UserName & "))"

tx

--
Jeromy Statia [MSFT]

This posting is provided "AS IS" with no warranties, and confers no rights.


Matthew Kaess said:
I have the piece of code that's supposed to do this -
Dim root As New System.DirectoryServices.DirectoryEntry
("LDAP://" & Domain)

Dim rootSearch As New
System.DirectoryServices.DirectorySearcher(root)
rootSearch.Filter = "samaccountname=" & UserName
Dim sResult As System.DirectoryServices.SearchResult =
rootSearch.FindOne
Try
Return sResult.Properties(PropertyName).Item(0)

Catch
Return "Property Not Found"
End Try


-----Original Message-----
the sAMAccountName should only be matthew not DOMAIN\matthew. They should
be binding using ldap://domain and using a ldap filter of
(&(objectclass=user)(sAMAccountName=matthew))

tx

--
Jeromy Statia [MSFT]

This posting is provided "AS IS" with no warranties, and confers no rights.


We are running a custom application which requests the
users mail property in AD for there email address. The
developers are using the DOMAIN\username syntax to query
AD for this information. The problem is it appears to be
using some soft of Ambiguous Name Resolution because it's
returning the wrong email address. Example;

The app is asking AD for the mail property of
sAMAccountName DOMAIN\matthew. The message is being sent
to user Cheryl Matthews instead. Any thoughts on what may
be occuring or how the developers can rewrite their code
to return the correct address? Thanx in advance!

Matthew Kaess


.
 
Back
Top