Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie - how to hide toolbar/link for spesific group

Status
Not open for further replies.

Winan

IS-IT--Management
Jan 1, 2002
83
0
0
ID
Dear all,

I am very new to SPS, I have just installed SPS 2003 on my Win 2003 Server, I had 2 groups of user, group A is administrator users who can do anything to portal and the others is just normal user who can only view and cannot do anything to portal.

What I need is when normal users logged in to portal then every toolbar / links for modifying the portal should be invisible.. , currently although they cannot modify anything to portal but they can still see the toolbar/link, how to deal with this?

please advise .. many thanks in advance

Regards

Winanjaya
 
Srry for posting again but 2 posts up (dated: 31 May 05 2:52) ignore the firts 2 lines! i was copying pasting and forgot to remove them!
 
Hi .. TIA, but I have no better progress...
What I did are:

1. Copy the dll into site folder
2. run Edit Page -> Modify Shared Page -> Add Web Parts -> Import -> Browse the .dwp -> click "Upload" button, after it uploaded then I drag it

then the result is

The "HideLinks" Web Part appears to be causing a problem.

Web Parts Maintenance Page: If you have permission, you can use this page to temporarily disable Web Parts or remove personal settings. For more information, contact your site administrator.

below is the latest version of the code..

Protected Overrides Sub RenderWebPart(ByVal output As System.Web.UI.HtmlTextWriter)
Dim sbText As StringBuilder = New StringBuilder
Dim SiteCollection As SPSite
Dim Web As SPWeb
' Using
'SiteCollection = New SPSite("<topSitePath>")
SiteCollection = SPControl.GetContextSite(Context)
Try
' Using
' Web = SiteCollection.OpenWeb
Web = SPControl.GetContextWeb(Context)
SiteCollection.CatchAccessDeniedException = False
sbText.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'>")
If Web.Permissions.DoesUserHavePermissions(SPRights.ManageWeb) Then
sbText.Append("<tr><td><hr></td></tr>")
sbText.Append("<tr><td><a href='_layouts/1043/settings.aspx'>Site-Settings</a></td></tr>")
sbText.Append("<tr><td><a href='_layouts/1043/create.aspx'>Create</a></td></tr>")
sbText.Append("<tr><td><a href='_layouts/1043/viewlsts.aspx'>Documents and Lists</a></td></tr>")
sbText.Append("<tr><td><a href='javascript:HelpWindowKey(%22NavBarHelpHome%22)'>Help</a></td></tr>")
End If
sbText.Append("</table>")
If Web.Permissions.DoesUserHavePermissions(SPRights.ManageWeb) Then
sbText.Append("<script type='text/javascript'>")
sbText.Append("document.getElementById('hidediv').style.visibility = 'visible';")
sbText.Append("</script>")
End If
output.Write(sbText.ToString)
Catch ex As Exception
output.Write("Ex: " & ex.Message + "<br>" + ex.StackTrace)
Finally
End Try
End Sub
 
>>1. Copy the dll into site folder
You mean in the bin folder of the site ?
you made the custimizations in the web.config?

you could still try and raise the first "Try" tag up to the top so all errors of the code are catched and see what it says.. as what i discribed in my last example.

also make sure that a copy of the webpart (DLL) is not located in the GAC..
 
Hi, I am very new with this.., sorry I am just asking.. how if I am not put the DLL into GAC and or modify the web.config .. I will get:

A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered on this site as safe.

when trying to drag the webpart into page..

please advise

Regards
Winanjaya
 
You should always put the safe tag in the web.config! After that you have to choice to either place the assembly in the bin folder OR in the GAC. If you place it in the bin folder you have to change the trust lvl to Full (again in the web.config).
 
Thanks a lot, it works ..

Regards
Winanjaya

 
Hi guys.
I am in similar type of situation. I have couple of groups who I dont want to show any link and My whole project is stuck at this. I have tried your codes and they worked fine beside when I drag and drop the web part on the page it give me an error, " Problem with the Web Page might prevent it from Displaying or function properly.......
Line:226
Char:1
Error:Object Required
Code :0
URL: "

just to let you know when I added the web part to portal main page it didnt give any error. I am also pasting my codes here. Please help i will really appriciate this help
do I have to install it in any particular way.? many thank in return

Imports System
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml.Serialization
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Utilities
Imports Microsoft.SharePoint.WebPartPages
Imports System.Text
Imports Microsoft.SharePoint.WebControls


'Description for WebPart1.
<DefaultProperty("Text"), ToolboxData("<{0}:WebPart1 runat=server></{0}:WebPart1>"), XmlRoot(Namespace:="Visible ")> _
Public Class Empview
Inherits Microsoft.SharePoint.WebPartPages.WebPart

'Private Const _defaultText As String = ""
'Private SiteCollection As SPSite = SPControl.GetContextSite(Context)
'Private SiteCollection As SPWeb = SPControl.GetContextWebWeb(Context)

Protected Overrides Sub RenderWebPart(ByVal output As System.Web.UI.HtmlTextWriter)
'Dim _text As String = _defaultText
Dim sbText As StringBuilder = New StringBuilder
Dim SiteCollection As SPSite
Dim Web As SPWeb
'Dim SPWeb As SPControl.GetContextSite(Context)
'Dim SPControl As

'SiteCollection = New SPSite("< SiteCollection = SPControl.GetContextSite(Context)
Try
Web = SPControl.GetContextWeb(Context)
SiteCollection.CatchAccessDeniedException = False
sbText.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'>")
If Web.Permissions.DoesUserHavePermissions(SPRights.ManageWeb) Then
sbText.Append("<tr><td><hr></td></tr>")
sbText.Append("<tr><td><a href='_layouts/1033/settings.aspx'>Site-Settings</a></td></tr>")
sbText.Append("<tr><td><a href='_layouts/1033/create.aspx'>Create</a></td></tr>")
sbText.Append("<tr><td><a href='_layouts/1033/viewlsts.aspx'>Documents and Lists</a></td></tr>")
sbText.Append("<tr><td><a href='javascript:HelpWindowKey(%22NavBarHelpHome%22)'>Help</a></td></tr>")
End If
sbText.Append("</table>")
If Web.Permissions.DoesUserHavePermissions(SPRights.ManageWeb) Then
sbText.Append("<script type='text/javascript'>")
sbText.Append("document.getElementById('hidediv').style.visibility = 'visible';")
sbText.Append("</script>")
End If
output.Write(sbText.ToString)
Catch ex As Exception
output.Write("Ex: " & ex.Message + "<br>" + ex.StackTrace)
Finally
End Try
'Try
'Catch ex2 As Exception
' output.Write("Ex2: " & ex2.Message + "<br>" + ex2.StackTrace)
'Finally
'End Try
End Sub

' Public Overrides Function ShouldSerializeAllowZoneChange() As Boolean

'End Function
End Class
 
Hi,

Only use this part

sbText.Append("<script type='text/javascript'>")
sbText.Append("document.getElementById('hidediv').style.visibility = 'visible';")
sbText.Append("</script>")

if you have placed a <div id='hidediv'> on the page with the webpart. And it must be above the location of the webpart or it might not exist when the code gets executed.

Greetings
 
Chaser.
Thank you for your help.The webpart is working fine, Now I have one more question. When we drag and drop the web part it create the toolbar which also generates HTML. Is there anyway we can create a web part which runs on a page load and check the permissions first and then show the links.I was wondering if there is anyways we can use Global Variable. Please advice if i fiqure out something I will send you an email.
Actualy I have Html Pages Integrated with Sharpoint aspx pages when I drag and drop the web part they screw the HTML on the page. Thank You for your help.
Regards
Attiq Khan
 
I am not sure what your aiming at the code of the web part runs when its loaded, and it ofcourse checks permissions first before generating any html or script too the page.

If you have hidden elements in a div they wont be visible if the webpart does not generate the script to make em visible. And that happens only after autentication.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top