Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am trying to use Active Directory to check the groups that the current user is a member of. I was trying to use

HttpContext.Current.User.IsInRole(role) and it always returned false. I am a member of the Domain\WebAdmin group, but

IsInRole("Domain\WebAdmin") returns false when it checks my account against active directory. My server OS is Windows 2000 Server.

 

I used the following function to run through the debugger and see if I was authenticating to active directory:

 

'=========================================================================================

Public Shared Function GetUserGroupMembership(ByVal strUser As String) As StringCollection

Dim groups As New StringCollection

�********************************************************************

� UsrName and PWD below are the username and password of a user I created with

�Administrator privileges in Active Directory

�*******************************************************************

Dim obEntry As New DirectoryEntry("LDAP://CN=users,DC=DOMAIN,DC=org", "UsrName", �PWD")

Dim srch As New DirectorySearcher(obEntry, "(sAMAccountName=" + strUser + ")")

Dim res As SearchResult = srch.FindOne()

If Not (Nothing Is res) Then

Dim obUser As New DirectoryEntry(res.Path)

' Invoke Groups method.

Dim obGroups As Object = obUser.Invoke("Groups")

Dim ob As Object

For Each ob In CType(obGroups, IEnumerable)

' Create object for each group.

Dim obGpEntry As New DirectoryEntry(ob)

groups.Add(obGpEntry.Name)

Next ob

End If

Return groups

End Function 'GetUserGroupMembership

'=================================================================================================

 

When objEntry is created I looked in the debugger and the following error was thrown for some properties of the object but the program doesn't crash yet:

�<error: an exceptionof type:{System.Runtime.InteropServices.COMException} occurred>�.

If I don't specify CN=users in my adsPath then I don't get this error, but I am still unable to use the DirectorySearcher object.

 

When I continue with the step through on the debugger the program crashes with the following error when the FindOne () method is called:

�System.Runtime.InteropServices.COMException: The authentication mechanism is unknown�

 

I can�t find any documentation for this error and I am new to using active directory, so I would appreciate any suggestions for things I can check.

 

Thanks in advance!

  • 2 years later...
Posted
Are you sending your user name and domain separately in the ldap string? if so, try combining them. that solved a similiar problem for me

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...