1
votes

I'm trying to reference an item in Sitecore. In my code, MyItem1 returns Null for {12345ABC-4784-4869-AD80-D90B07350835}.

I am able to reference the item for the "Regular User" but not for the "Special User". Could this be a permissions issue?

Note: The "special user" item exists in both the master and the web db.

    Dim SCDataItemValue As String = ""
    Dim ADGroupValue As String = ""

    If Not Request.QueryString("type") Is Nothing AndAlso Request.QueryString("type").ToString.ToLower.Trim = "special" Then
        'Get values for Special User.
        SCDataItemValue = "{12345ABC-4784-4869-AD80-D90B07350835}"
        ADGroupValue = "GroupAccess_Special"
    Else
        'Regular User.
        SCDataItemValue = "{1911A077-2E41-4CAB-ADAC-1911A077EB62}"
        ADGroupValue = "GroupAccess"
    End If

    Dim scItemID As New Sitecore.Data.ID(SCDataItemValue)
    Dim MyItem1 As Sitecore.Data.Items.Item = Sitecore.Context.Database.GetItem(scItemID)
2
I've notices something else. When I use a different existing item's guid for the special user, the MyItem1 is NOT null. When I create a new items, MyItem1 returns Null. If I create a duplicate of an existing item that works, then the new duplicate will not work.crjunk

2 Answers

4
votes

Yes can be a permission issue. Maybe that user doesn't have read permission for item ; If you want to have full access control to your items please use :

  // The SecurityDisabler overrides the current security model, allowing you
 // to access the item without any security. It's like the user being an administrator

 using (new Sitecore.SecurityModel.SecurityDisabler())
        {
  Dim scItemID As New Sitecore.Data.ID(SCDataItemValue)
  Dim MyItem1 As Sitecore.Data.Items.Item = Sitecore.Context.Database.GetItem(scItemID)
        }

I don't know how code is exactly in Visual Basic .

2
votes

sitecore climber is probably right in stating this to be a security issue. Try using the 'Access Viewer' (Sitecore > Security Tools > Access Viewer) to see if your user has read access to the item in question. Tip: in the access viewer, select the user/role from the 'Users' chunk.