P
Paul East
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 (http://support.microsoft.com/default.aspx?scid=kb;EN-US;326340)
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")(propertyCounter), 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
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")(propertyCounter), 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