H
Harold
Can someone explain to me why IsInRole will work, but using
DirectorySearcher will not? The code is running in a business object behind
a webservice. The user's credentials (windows authenication) are being
passed to the webservice. The webservice is configured for "integrated
windows authenication" and no "anonymous access".
The error "An operations error occurred" occurs when FindOne is executed.
The LDAP information is good as it works when it is not behind the
webservice.
If this is because of the double-hop of a token, how can IsInRole use the
token and not DirectorySearcher?
Here's the code:
For using LDAP:
ID = CType(System.Threading.Thread.CurrentPrincipal.Identity,
WindowsIdentity)
ImpersonateContext = ID.Impersonate()
oLDPA = New DirectoryEntry(LDAP://ServerName/DC=name1,DC=name2,DC=net)
oSearch = New DirectorySearcher(oLDPA)
oGroups = New Hashtable
With oSearch
.Filter =
String.Format("(&(objectCategory=person)(objectClass=user)(sAMAccountName={0
}))", Split(System.Threading.Thread.CurrentPrincipal.Identity.Name, "\")(1))
.CacheResults = False
.PropertyNamesOnly = True
.ReferralChasing = ReferralChasingOption.All
Dim iSearchResult As SearchResult = .FindOne
End With
For using IsInRole:
If System.Threading.Thread.CurrentPrincipal.IsInRole(sGroup) Then
Thanks,
Harold
DirectorySearcher will not? The code is running in a business object behind
a webservice. The user's credentials (windows authenication) are being
passed to the webservice. The webservice is configured for "integrated
windows authenication" and no "anonymous access".
The error "An operations error occurred" occurs when FindOne is executed.
The LDAP information is good as it works when it is not behind the
webservice.
If this is because of the double-hop of a token, how can IsInRole use the
token and not DirectorySearcher?
Here's the code:
For using LDAP:
ID = CType(System.Threading.Thread.CurrentPrincipal.Identity,
WindowsIdentity)
ImpersonateContext = ID.Impersonate()
oLDPA = New DirectoryEntry(LDAP://ServerName/DC=name1,DC=name2,DC=net)
oSearch = New DirectorySearcher(oLDPA)
oGroups = New Hashtable
With oSearch
.Filter =
String.Format("(&(objectCategory=person)(objectClass=user)(sAMAccountName={0
}))", Split(System.Threading.Thread.CurrentPrincipal.Identity.Name, "\")(1))
.CacheResults = False
.PropertyNamesOnly = True
.ReferralChasing = ReferralChasingOption.All
Dim iSearchResult As SearchResult = .FindOne
End With
For using IsInRole:
If System.Threading.Thread.CurrentPrincipal.IsInRole(sGroup) Then
Thanks,
Harold