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 [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => <23DDF00C-8D75-42F9-BC92-0232E13A5C3B@microsoft.com> [ref] => [htmlstate] => on_nl2br [postusername] => Paul East [ip] => paul.east@gmacr [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 1 [islastshown] => [isfirstshown] => 1 [attachments] => [allattachments] => ) --> The error occours when the line below is uncommented: > 'Dim propertyCount As Integer =[/quote] result.Properties("memberOf").Count[quote] > > 'Dim dn As String > 'Dim equalsIndex, commaIndex > > 'Dim propertyCounter As Integer > > 'For propertyCounter = 0 To propertyCount - 1 > 'dn =[/quote] CType(result.Properties("memberOf")(propertyCounter), String)[quote] > > 'equalsIndex = dn.IndexOf("=", 1) > 'commaIndex = dn.IndexOf(",", 1) > 'If (equalsIndex = -1) Then > 'Return Nothing > 'End If > > 'groupNames.Append(dn.Substring((equalsIndex + 1),[/quote] (commaIndex - equalsIndex) - 1))[quote] > 'groupNames.Append("|") > 'Next > > Catch ex As Exception > Throw New Exception("Error obtaining group names. " &[/quote] ex.Message)[quote] > End Try > > Return groupNames.ToString() > End Function[/quote] [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => <#59mBZ5$DHA.3004@TK2MSFTNGP10.phx.gbl> [ref] => <23DDF00C-8D75-42F9-BC92-0232E13A5C3B@microsoft.com> [htmlstate] => on_nl2br [postusername] => Beginner [ip] => bzhang@hotmail. [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 2 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> Problems when authenticating against the Active Directory using Forms Authentication and Visual Basic .NET - ASP.NET Security
Professional Web Applications Themes

Problems when authenticating against the Active Directory using Forms Authentication and Visual Basic .NET - ASP.NET Security

I have recently followed the doent 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 ...

  1. #1

    Default Problems when authenticating against the Active Directory using Forms Authentication and Visual Basic .NET

    I have recently followed the doent 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

  2. #2

    Default 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.eastgmacrfc.co.uk> wrote in message
    news:23DDF00C-8D75-42F9-BC92-0232E13A5C3Bmicrosoft.com...
    > I have recently followed the doent 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 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 =
    result.Properties("memberOf").Count
    >
    > 'Dim dn As String
    > 'Dim equalsIndex, commaIndex
    >
    > 'Dim propertyCounter As Integer
    >
    > 'For propertyCounter = 0 To propertyCount - 1
    > 'dn =
    CType(result.Properties("memberOf")(propertyCounte r), String)
    >
    > 'equalsIndex = dn.IndexOf("=", 1)
    > 'commaIndex = dn.IndexOf(",", 1)
    > 'If (equalsIndex = -1) Then
    > 'Return Nothing
    > 'End If
    >
    > 'groupNames.Append(dn.Substring((equalsIndex + 1),
    (commaIndex - equalsIndex) - 1))
    > 'groupNames.Append("|")
    > 'Next
    >
    > Catch ex As Exception
    > Throw New Exception("Error obtaining group names. " &
    ex.Message)
    > End Try
    >
    > Return groupNames.ToString()
    > End Function

    Beginner Guest

  3. #3

    Default 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

  4. #4

    Default 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.eastGMACRFC.co.uk> wrote in message
    news:540950F3-C861-46CE-BFDD-C476457AA72Cmicrosoft.com...
    > 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.

    Beginner Guest

Similar Threads

  1. Asp.Net Forms authentication using Active Directory
    By Egbert in forum ASP.NET Security
    Replies: 1
    Last Post: November 3rd, 04:02 PM
  2. Replies: 2
    Last Post: April 9th, 01:53 PM
  3. Replies: 3
    Last Post: February 10th, 08:38 PM
  4. Active Directory, LDAP and Forms Authentication Problem
    By Ken Dourado in forum ASP.NET Security
    Replies: 0
    Last Post: November 10th, 07:01 PM
  5. Replies: 0
    Last Post: August 7th, 12:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139