Ask a Question related to ASP.NET Security, Design and Development.
-
Paul East #1
Problems when authenticating against the Active Directory using Forms Authentication and Visual Basic .NET
I have recently followed the document to allow authentication against Active Directory using Forms authentication as described in the the Microsoft Knowledge Base Article 326340 ([url]http://support.microsoft.com/default.aspx?scid=kb;EN-US;326340[/url])
I can authenticate correctly, but when I attempt to retrieve the groups for the user I get the following error
Object reference not set to an instance of an object
I have changed the code slightly to pull back the properties I have access to for the user but memberOf is not listed
Have I missed something, or is there some AD configuration needed to expose this
The code I'm working with is below
I hope someone can assist me with this
Thanks in advance
Paul Eas
Public Function GetGroups() As Strin
Dim search As DirectorySearcher = New DirectorySearcher(_path
search.Filter = "(cn=" & _filterAttribute & ")
search.PropertiesToLoad.Add("memberOf"
Dim groupNames As StringBuilder = New StringBuilde
Tr
Dim result As SearchResult = search.FindOn
'---------------> The error occours when the line below is uncommented
'Dim propertyCount As Integer = result.Properties("memberOf").Coun
'Dim dn As Strin
'Dim equalsIndex, commaInde
'Dim propertyCounter As Intege
'For propertyCounter = 0 To propertyCount -
'dn = CType(result.Properties("memberOf")(propertyCounte r), String
'equalsIndex = dn.IndexOf("=", 1
'commaIndex = dn.IndexOf(",", 1
'If (equalsIndex = -1) The
'Return Nothin
'End I
'groupNames.Append(dn.Substring((equalsIndex + 1), (commaIndex - equalsIndex) - 1)
'groupNames.Append("|"
'Nex
Catch ex As Exceptio
Throw New Exception("Error obtaining group names. " & ex.Message
End Tr
Return groupNames.ToString(
End Function
Paul East Guest
-
Asp.Net Forms authentication using Active Directory
Hi. I am using forms authentication in ASP.Net against Active Directory. I have followed the example provided by Microsoft. Here is my problem.... -
Role based Forms Authentication (using Active Directory)
Hi All, Can anybody here kindly forward me a sample of a Role based forms Authentication using Acitve Directory? Thanks alot. P -
Forms Authentication with Active Directory using vb.net
I have seen many examples of form authentication using c#. Can someone point me to a sample using vb.net. I would like to use WinNT://domain,... -
Forms or windows authentication with active directory?
Hi, I'm having a hard time deciding (figuring out) how to implement security in my asp.net application. Requirements: - Use active directory as... -
Active Directory, LDAP and Forms Authentication Problem
Hi, I've got an intranet ASP.NET application that uses Forms Authentication. What I'd like to do is get the username (in the format name.surname)... -
Beginner #2
Re: Problems when authenticating against the Active Directory using Forms Authentication and Visual Basic .NET
Someone does not have MemberOf properties. You need to test If
result.Contains("MemberOf"), or something like that. It's a pain if you
have a long list, hope they change the behavior in the futuer to treat null
as empty string.
"Paul East" <paul.east@gmacrfc.co.uk> wrote in message
news:23DDF00C-8D75-42F9-BC92-0232E13A5C3B@microsoft.com...Active Directory using Forms authentication as described in the the> I have recently followed the document to allow authentication against
Microsoft Knowledge Base Article 326340
([url]http://support.microsoft.com/default.aspx?scid=kb;EN-US;326340[/url]).for the user I get the following error:>
> I can authenticate correctly, but when I attempt to retrieve the groupsto for the user but memberOf is not listed.>
> Object reference not set to an instance of an object.
>
> I have changed the code slightly to pull back the properties I have accessexpose this?>
> Have I missed something, or is there some AD configuration needed toresult.Properties("memberOf").Count>
> The code I'm working with is below.
>
> I hope someone can assist me with this,
>
> Thanks in advance,
>
> Paul East
>
> Public Function GetGroups() As String
> Dim search As DirectorySearcher = New DirectorySearcher(_path)
> search.Filter = "(cn=" & _filterAttribute & ")"
> search.PropertiesToLoad.Add("memberOf")
>
> Dim groupNames As StringBuilder = New StringBuilder
>
> Try
> Dim result As SearchResult = search.FindOne
>
> '---------------> The error occours when the line below is uncommented:
> 'Dim propertyCount As Integer =CType(result.Properties("memberOf")(propertyCounte r), String)>
> 'Dim dn As String
> 'Dim equalsIndex, commaIndex
>
> 'Dim propertyCounter As Integer
>
> 'For propertyCounter = 0 To propertyCount - 1
> 'dn =(commaIndex - equalsIndex) - 1))>
> 'equalsIndex = dn.IndexOf("=", 1)
> 'commaIndex = dn.IndexOf(",", 1)
> 'If (equalsIndex = -1) Then
> 'Return Nothing
> 'End If
>
> 'groupNames.Append(dn.Substring((equalsIndex + 1),ex.Message)> 'groupNames.Append("|")
> 'Next
>
> Catch ex As Exception
> Throw New Exception("Error obtaining group names. " &> End Try
>
> Return groupNames.ToString()
> End Function
Beginner Guest
-
Paul East #3
Re: Problems when authenticating against the Active Directory using Forms Authentication and Visual Basic .NET
Thanks Beginner
The memberOf attribute is definately not in the list of exposed attributes from the code I posted
Has anyone else tried this code against their AD
Paul.
Paul East Guest
-
Beginner #4
Re: Problems when authenticating against the Active Directory using Forms Authentication and Visual Basic .NET
Didn't quite get what you are trying to say. You mean you didn't use
memberOf?
"Paul East" <paul.east@GMACRFC.co.uk> wrote in message
news:540950F3-C861-46CE-BFDD-C476457AA72C@microsoft.com...from the code I posted.> Thanks Beginner,
>
> The memberOf attribute is definately not in the list of exposed attributes>
> Has anyone else tried this code against their AD?
>
> Paul.
Beginner Guest



Reply With Quote

