.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Does SPWeb.DoesUserHavePermissions() & SPWeb.GetSubwebsForCurrentUser work with users assigned to a

Posted By:      Posted Date: October 15, 2010    Points: 0   Category :SharePoint

Does SPWeb.DoesUserHavePermissions() &  SPWeb.GetSubwebsForCurrentUser work with users assigned to an AD security group? 

In other words, the user is not assigned directly to a SharePoint security group...but indirectly through an AD security group.

Any ideas? I have a requirement where only AD security groups will be assigned to SharePoint permissions.



View Complete Post

More Related Resource Links

Adding users with SPweb.EnsureUser("Username"); where Username does not come from the Network/LAN/Ac

Like the title states, I can add users who are listed in active director.  However,  for some testing issues i have going on with permissions and security, I would like to add a list of 'Users' from a database table i created;  programmically of course. How do i get my sharepoint application to understand this?   Regards, max



hi all,

I'm trying to imitate what Sharepoint does when a user clicks on a file name and gets a dialog box for a read only access to the file. I have binged and googled and yahooed and asked and some others I forgot looking for ways of doing it in code using the sharePoint object model to no avail.

Can somebody share a little bit of knowledge on how I might start doing this or where to look for the informations.

What I'm trying to do is to bring the checking/checkout functionality to a gridview. I got the check-in/out ok but I have not been able to accomplish the file view in read only mode. using the postback url I can see the file but it comes as read/write and once I select the file then the link controls I'm using on the grid are deactivated and can't find out why.

this is the code I use to view the file..
control.PostBackUrl = string.Format("{0}{1}", urlHdr, row.Field<string>("FileLeafRef")); // this does not work!


Login to SPSite\SPWeb through console app using user/password

Hi,I'm developing some basic console application which interacts with SharePoint site through the object mode. I'm using:SPSite site = new SPSite(MySiteUrl); SPWeb web = site.OpenWeb(); This way, current windows user is acessing the site. Is it possible to supply the user with username/password to be able to acess with different credentials than current?Thanks in advance!

Best way to query SPWeb propertybag

I have thousands of subsites that have all their data stored in propertybags in SharePoint 2010.  I need to query the SPWeb propertybag at the top site level for summations and some custom webparts.  I was wondering what was the best way to do this?  I not sure if the new LINQ To SQL will help with this or what the best solution would be.  Right now I'm just looping through all the subsites but their has to be a better way...  Any help is much appreciated!

First Development Program with SPSite, SPWeb and SPList works only locally but not in farm

Dear All, Here is a piece of code which wrote in a VS 2010 with Standlone Sharepoint 2010 in Windows 7 64 bit and it works fine. Private Shared _SiteURL As String     Private Shared Sub Initialize(ByVal SiteURL As String)                 _SiteURL = SiteURL         Using sc As New SPSite(_SiteURL)             Dim spWebSite As SPWeb = sc.RootWeb             _AllSPList = New List(Of String)             _HiddenSPList = New List(Of String)             _VisibleSPList = New List(Of String)             For Each item As SPList In spWebSite.Lists                 _AllSPList.Add(item.Title)                 If item.Hidden = True Then                     _HiddenSPList.Add(item.Title)             &nb

disposing SPSite and SPWeb objects?

hi          can i code using(SPSite oSite=SPContext.Current.Site) {    using(SPWeb oWeb=oSite.OpenWeb()) {} } or should i code like this SPSite oSite=SPContext.Current.Site; using(SPWeb oWeb=oSite.Openweb()){} which is better? i am trying to code this inside ItemAdding Event handler. please suggest

SPWeb.Properties is not persist over the redirect page.

Hi, I have to pass some object from my code to another redirected page. So I serialize the object and serialized string is save to SPWeb's property as a string and after that I use SPUtility.Redirect('Url'). But on redirected page above updated property is not find in the SPWeb.Property collection. string xml = MyClass.GetXMLFromObject(exInfo); SPContext.Current.Web.Site.RootWeb.AllowUnsafeUpdates = true; SPContext.Current.Web.Site.RootWeb.Update(); if (!SPContext.Current.Web.Site.RootWeb.Properties.ContainsKey("MyInfo")) { SPContext.Current.Web.Site.RootWeb.Properties.Add("MyInfo", xml); SPContext.Current.Web.Site.RootWeb.Update(); } else { SPContext.Current.Web.Site.RootWeb.Properties["MyInfo"] = xml; SPContext.Current.Web.Site.RootWeb.Update(); } SPContext.Current.Web.Site.RootWeb.AllowUnsafeUpdates = false; SPContext.Current.Web.Site.RootWeb.Update(); SPUtility.Redirect("RedirectToErrorPage/ApplicationPage1.aspx?ExInfo=" +xml, SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current); Redirected page code: if (SPContext.Current.Web.Site.RootWeb.Properties["MyInfo"] != null) { using (SPWeb web = SPContext.Current.Site.OpenWeb(SPContext.Current.Web.Site.RootWeb.Url)) { TextBox1.Text = Convert.ToString(SPContext.Current.Web.Site.Root

'AllowUnsafeUpdates' property on SPWeb - Ask urgently for assistance!

<!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } --> Hi all, since two days I look without success for a solution for an update, which because of - Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb. - can not be accomplished. My assumption is that the error could have to do something with the implemented context. I am missing the necessary know-how to limit the Error. Would be grateful for each assistance! Thank you in advance.     The Exception ist thrown in this function (at roleAssignments.Add(roleAssignment); ):   //create role deinition for the customer public void DefineCustomerRole() { SPSecurity .RunWithElevatedPrivileges( delegate () { using ( SPSite spSite = this .GetSetCurrentSite) { using ( SPWeb spWeb = this .GetSetCurrentWeb) { // Break permission level inheritance if exists, than set new permissions if (!spWeb.HasUniqueRoleDefinitions) spWeb.RoleDefinitions.BreakInheritance( true , true );   string CustomGroupName = this .GetSetCustomGroupName; SPRoleDefinitionCollection roleCollection = spWeb.RoleDefinitions; SPRoleAssignmentCollection roleAssignments = spWeb.RoleAssignments; SPWeb spWebRoot = spWeb.Site.RootWeb; spWeb.Update(); spWebRoot.AllowUnsafeUpdates = true ; spSite.AllowUnsafeUpdates = true ; SPWebApplication webApp = spWe

Export-SPWeb "cannot find spweb object with id or url" error

How do we just export and import a library or a list using Export-SPWeb and Import-SPWeb? I tried exporting just a library with Export-SPWeb, but it throws an error : Could not find an SpWeb Object with Id or URL “http://<server:port>/Shared Documents”. The same thing goes for a simple list like Tasks: "http://<server:port>/Lists/Tasks". Any help would be much appreciated

179 heaps created, above warning threshold of 32. Check for excessive SPWeb or SPSite usage.

Hi All, I am gettings hundreds of following error messages in my sharepoint log files 179 heaps created, above warning threshold of 32. Check for excessive SPWeb or SPSite usage. Also I have noticed that after these error messages my sharepoint site is now dead slow. Any idea how to resolve this problem ?  

Microsoft.SharePoint.SPWeb does not contain a definition for SetAvailableCrossLanguageWebTemplates

I'm trying to mess around with this code example found here: http://www.tonstegeman.com/Blog/Lists/Posts/Post.aspx?List=70640fe5-28d9-464f-b1c9-91e07c8f7e47&ID=71 To learn about limiting what templates are available in various site collections. But, I can't compile the code, due to the above error. According to the documentation, SPWeb should have that definition. But, intellisense doesn't list it, either. It's happening on this line: web.SetAvailableCrossLanguageWebTemplates(templates); If I check to see what intellisense things "web" is, it thinks it's an SPWeb. I'm confused. Help?

newlly added content type not exist in SPWeb.ContentTypes


I use a C# application (it uses stsadm.exe) to deploy a content type, and in the same program, I try to get the content type by using SPWeb.ContentTypes[name] right after the content type is deployed,  it returns null. if i exist the c# application and re-run the application, I can get the added content type. I don't know why I cannot get the content type the first time after the content type is deployed. Any thoughts?




Setting a theme using Set-SPWeb


On SP10, I tried to set a theme for a web using Set-SPWeb commandlet as below.


Set-SPWeb -Identity $UnitsADM -Theme "Laminate"


However, I got an error saying "couldn't open the folder Laminate".

Please anyone drop me a sample line of commandlet setting a theme. Thank you!

SPWeb.ProcessBatchData for Checkout, checkin & Publish


I have a listItem.update() inside a loop (around a dozen of items are updated).

Instead of using ListItem.update() - I want to use the SPWeb.ProcessBatchData.
The list item i use above is a Publishing Page, so I have todo checkout, checkin and Publish as well.

Can anyone tell how I can Checkout, checkin & Publish an item thru ProcessBatchData ??

- Kiruthik

import-spweb changes some values (create date, modified...)


all my Imported items (export-spweb - >import-spweb) have today's date now.
And the creater is now mydomain\administrator.

Can I fix this somewhere ?
Maybe in a SQL table ?


Error opening site using SPSite and SPWeb instances using VS 2010, Win Server 2008 R2


Hi I am trying to open my site using SPSite and SPWeb instances and getting an error message as below-

The Web application at http://url could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

  CODE is -



                    SPSite siteCOll = new SPSite(siteURL);

                    SPWeb oWeb = siteCOll.OpenWeb("url");



I can access site using browser perfectly.

I am running VS as administrator.

I have done permission checking aswell.


please help!





Error occured when using SPWeb or SPSite in webpart


I am creating a custom webpart, in which I have a label control. This label will display the current site URL and here is the code

protected override void CreateChildControls()
            SPWeb wb = SPContext.Current.Web;
            string baseURL = wb.Url.ToString();
            Label lblTitle = new Label();
            lblTitle.Text = baseURL.ToString();

But when I try to use SPWeb or SPSite within CreateChildControl method, I am getting an unexpected error occurred message. Also I have used "using Microsoft.SharePoint;" too.

If suppose I comment those two line my web part is displaying the properly. As below

protected override void CreateChildControls()
            //SPWeb wb = SPContext.Current.W

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend