Search Results

Search found 82 results on 4 pages for 'spsite'.

Page 2/4 | < Previous Page | 1 2 3 4  | Next Page >

  • OpenWeb(String) method

    - by ybbest
    I guess this is a SharePoint beginner problem ,however it took me a while to figure out what the problem is and I will blog it to help me to remember. Basically I wrote the following code to grab some list item from my SharePoint subsite http://win-oirj50igics/RestAPI,however I got the error stating that : “<nativehr>0×80070002</nativehr><nativestack></nativestack>There is no Web named / http://win-oirj50igics/RestAPI”. The problem is that OpenWeb(String) method returns the web site that is located at the specified server-relative or site-relative URL. It is the relative URL , so after I changed http://win-oirj50igics/RestAPI to RestAPI, everything works fine. using (SPSite site = new SPSite(http://win-oirj50igics/)) { SPWeb web = site.OpenWeb("http://win-oirj50igics/RestAPI"); SPQuery query = new SPQuery(); query.Query = camlDocument.InnerXml; SPListItemCollection items = web.Lists["Songs"].GetItems(query); IEnumerable<Song> sortedItems = from item in items.OfType<SPListItem>() orderby item.Title select new Song {SongName = item.Title, SongID = item.ID}; songs.AddRange(sortedItems); }

    Read the article

  • SPNavigationNode.IsVisible property not working as expected.

    - by Manish
    My code is as under: using (SPSite spSiteTest = new SPSite(serverUrl)) { using (SPWeb mySite = spSiteTest.OpenWeb()) { SPNavigationNodeCollection quickLaunchNodes = mySite.Navigation.QuickLaunch; SPNavigationNode navQuickNode = new SPNavigationNode("Title", "www.stackoverflow.com", true); foreach (SPNavigationNode node in quickLaunchNodes) { if (node.Title == navQuickNode.Title) { node.Url = navQuickNode.Url; node.IsVisible = isVisible; node.Update(); //mySite.Update(); return; } } quickLaunchNodes.AddAsFirst(navQuickNode); } } I want to hide a quick launch node but using the above code, it's not working. :( Am I missing something?

    Read the article

  • Sharepoint : Access denied when editing a page (because of page layout) or list item

    - by tinky05
    I'm logged in as the System Account, so it's probably not a "real access denied"! What I've done : - A custom master page - A custom page layout from a custom content type (with custom fields) If I add a custom field (aka "content field" in the tools in SPD) in my page layout, I get an access denied when I try to edit a page that comes from that page layout. So, for example, if I add in my page layout this line in a "asp:content" tag : I get an access denied. If I remove it, everyting is fine. (the field "test" is a field that comes from the content type). Any idea? UPDATE Well, I tried in a blank site and it worked fine, so there must be something wrong with my web application :( UPDATE #2 Looks like this line in the master page gives me the access denied : <SharePoint:DelegateControl runat="server" ControlId="PublishingConsole" Visible="false" PrefixHtml="&lt;tr&gt;&lt;td colspan=&quot;0&quot; id=&quot;mpdmconsole&quot; class=&quot;s2i-consolemptablerow&quot;&gt;" SuffixHtml="&lt;/td&gt;&lt;/tr&gt;"></SharePoint:DelegateControl> UPDATE #3 I Found http://odole.wordpress.com/2009/01/30/access-denied-error-message-while-editing-properties-of-any-document-in-a-moss-document-library/ Looks like a similar issue. But our Sharepoint versions are with the latest updates. I'll try to use the code that's supposed to fix the lists and post another update. ** UPDATE #4** OK... I tried the code that I found on the page above (see link) and it seems to fix the thing. I haven't tested the solution at 100% but so far, so good. Here's the code I made for a feature receiver (I used the code posted from the link above) : using System; using System.Collections.Generic; using System.Text; using Microsoft.SharePoint; using System.Xml; namespace MyWebsite.FixAccessDenied { class FixAccessDenied : SPFeatureReceiver { public override void FeatureActivated(SPFeatureReceiverProperties properties) { FixWebField(SPContext.Current.Web); } public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { //throw new Exception("The method or operation is not implemented."); } public override void FeatureInstalled(SPFeatureReceiverProperties properties) { //throw new Exception("The method or operation is not implemented."); } public override void FeatureUninstalling(SPFeatureReceiverProperties properties) { //throw new Exception("The method or operation is not implemented."); } static void FixWebField(SPWeb currentWeb) { string RenderXMLPattenAttribute = "RenderXMLUsingPattern"; SPSite site = new SPSite(currentWeb.Url); SPWeb web = site.OpenWeb(); web.AllowUnsafeUpdates = true; web.Update(); SPField f = web.Fields.GetFieldByInternalName("PermMask"); string s = f.SchemaXml; Console.WriteLine("schemaXml before: " + s); XmlDocument xd = new XmlDocument(); xd.LoadXml(s); XmlElement xe = xd.DocumentElement; if (xe.Attributes[RenderXMLPattenAttribute] == null) { XmlAttribute attr = xd.CreateAttribute(RenderXMLPattenAttribute); attr.Value = "TRUE"; xe.Attributes.Append(attr); } string strXml = xe.OuterXml; Console.WriteLine("schemaXml after: " + strXml); f.SchemaXml = strXml; foreach (SPWeb sites in site.AllWebs) { FixField(sites.Url); } } static void FixField(string weburl) { string RenderXMLPattenAttribute = "RenderXMLUsingPattern"; SPSite site = new SPSite(weburl); SPWeb web = site.OpenWeb(); web.AllowUnsafeUpdates = true; web.Update(); System.Collections.Generic.IList<Guid> guidArrayList = new System.Collections.Generic.List<Guid>(); foreach (SPList list in web.Lists) { guidArrayList.Add(list.ID); } foreach (Guid guid in guidArrayList) { SPList list = web.Lists[guid]; SPField f = list.Fields.GetFieldByInternalName("PermMask"); string s = f.SchemaXml; Console.WriteLine("schemaXml before: " + s); XmlDocument xd = new XmlDocument(); xd.LoadXml(s); XmlElement xe = xd.DocumentElement; if (xe.Attributes[RenderXMLPattenAttribute] == null) { XmlAttribute attr = xd.CreateAttribute(RenderXMLPattenAttribute); attr.Value = "TRUE"; xe.Attributes.Append(attr); } string strXml = xe.OuterXml; Console.WriteLine("schemaXml after: " + strXml); f.SchemaXml = strXml; } } } } Just put that code as a Feature Receiver, and activate it at the root site, it should loop trough all the subsites and fix the lists. SUMMARY You get an ACCESS DENIED when editing a PAGE or an ITEM You still get the error even if you're logged in as the Super Admin of the f****in world (sorry, I spent 3 days on that bug) For me, it happened after an import from another site definition (a cmp file) Actually, it's supposed to be a known bug and it's supposed to be fixed since February 2009, but it looks like it's not. The code I posted above should fix the thing.

    Read the article

  • How to add ACTIVE DIRECTORY user to Sharepoint group

    - by standley-nguyen
    Hi all. I got an exception when executing this snippet code SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(siteUrl.Trim())) { using (SPWeb web = site.OpenWeb()) { try { web.AllowUnsafeUpdates = true; SPUser spUser = web.AllUsers[userName]; if (spUser != null) { SPGroup spGroup = web.Groups[groupName]; if (spGroup != null) spGroup.AddUser(spUser); } } catch (Exception ex) { this.TraceData(LogLevel.Error, "Error at function Named [AddUserToSPGroupWidget.AddUserToGroup] . With Error Message: " + ex.ToString()); } finally { web.AllowUnsafeUpdates = false; } } } }); PLease guide me. Thanks in advance.

    Read the article

  • How to add ACTIVE DOMAIN user to Sharepoint group

    - by standley-nguyen
    Hi all. I got an exception when executing this snippet code SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(siteUrl.Trim())) { using (SPWeb web = site.OpenWeb()) { try { web.AllowUnsafeUpdates = true; SPUser spUser = web.AllUsers[userName]; if (spUser != null) { SPGroup spGroup = web.Groups[groupName]; if (spGroup != null) spGroup.AddUser(spUser); } } catch (Exception ex) { this.TraceData(LogLevel.Error, "Error at function Named [AddUserToSPGroupWidget.AddUserToGroup] . With Error Message: " + ex.ToString()); } finally { web.AllowUnsafeUpdates = false; } } } }); PLease guide me. Thanks in advance.

    Read the article

  • Access denied when using RunWithElevatedPrivileges?

    - by James123
    I want regular user can access the "User Information List" in Mysite root site. I am using "RunWithElevatedPrivileges" method. Still throwing access denied error. per example my root site collection for mysite is "http://network.test.com". the user want assess userinformation list this site collection. How can he access that? SPSecurity.RunWithElevatedPrivileges(delegate { using (SPSite site = new SPSite(SPContext.Current.Web.Site.ID)) { ServerContext sc = ServerContext.Current; UserProfileManager upm = new UserProfileManager(sc); UserProfile up = null; //get current user's profile (visitor) if (upm.UserExists(SPContext.Current.Web.CurrentUser.LoginName)) { up =upm.GetUserProfile(SPContext.Current.Web.CurrentUser.LoginName); SPWeb web = SPContext.Current.Web; SPList userInformationList = web.Lists["User Information List"];

    Read the article

  • SPNavigationNode.IsVisible property not working in sharepoint as expected.

    - by Manish
    I want to hide a quick launch node in a sharepoint site, but it's not working as expected. :( My code is as under: using (SPSite spSiteTest = new SPSite(serverUrl)) { using (SPWeb mySite = spSiteTest.OpenWeb()) { SPNavigationNodeCollection quickLaunchNodes = mySite.Navigation.QuickLaunch; SPNavigationNode navQuickNode = new SPNavigationNode("Title", "www.stackoverflow.com", true); foreach (SPNavigationNode node in quickLaunchNodes) { if (node.Title == navQuickNode.Title) { node.Url = navQuickNode.Url; node.IsVisible = isVisible; node.Update(); //mySite.Update(); return; } } quickLaunchNodes.AddAsFirst(navQuickNode); } } Am I missing something or is it a bug?

    Read the article

  • any way to get sharepoint groups with a given site url

    - by standley-nguyen
    Hi all. I'm getting a stuck. Suppose that I create 5 sites. For each one, I create a few sharepoint groups. So, I create a dropdownlist control to bind 5 sites and when I click on any site there, I will get sharepoint groups created on it. But I always see the dropdownlist used to bind these groups still never change. I mean it only binds a few default groups in sahrepoint everytime. The new created groups is not. And I have confusion like this web.AssociatedGroups web.Groups web.SiteGroups which one we will use this case ? Please guide me Here my snippet code private void BindSPGroupsToDropDownList(DropDownList ddl, string siteUrl) { ddl.Items.Clear(); try { SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(siteUrl)) { using (SPWeb web = site.OpenWeb()) { //web.SiteGroups foreach (SPGroup spGroup in web.Groups) { ddl.Items.Add(new ListItem(spGroup.Name.Trim(), spGroup.ID.ToString())); } } } }); } } thanks in advance

    Read the article

  • Updating the url of a navigation node in moss programatically

    - by 78lro
    Can anyone see why this should not work: SPSite topNavigationSite = new SPSite("http://moss"); SPWeb topNavigationWeb = topNavigationSite.OpenWeb(); SPNavigationNodeCollection topNavigationBarNodes = topNavigationWeb.Navigation.TopNavigationBar; SPNavigationNode updateNode = topNavigationBarNodes.Navigation.GetNodeByUrl("/about"); updateNode.Url = ""; topNavigationWeb.Update(); I can see debugging that the url get's set to "" but when the page renders, the navigation still shows the url as /about/default.aspx I'm running this in page_load and expected it to update the moss database with the new url value.

    Read the article

  • SharePoint Navigation - Setting the Audience Property of an SPNavigationNode

    - by jhallal
    In this tip/trick i will demonstrate a way of setting by code the target audience of an SP navigation node.You might say setting this property in SharePoint UI is quite simple, but if you want to set it by code you will not find any straight forward property or method out of the box in SharePoint Object Model that does the job. The SPNavigationNode class has a property called “Properties”, which allows us to add custom properties to the node. One of the Property is “Audience”, which is used for setting the target audience on the navigation node. using (SPSite site = new SPSite("URL of your SharePoint Site")) {                using (SPWeb web = site.OpenWeb())         {             SPNavigationNode navNode = web.Navigation.GlobalNodes[0];              if (navNode.Properties.Contains("Audience"))             {                 navNode.Properties["Audience"] = "Users or Groups";             }             else             {                 navNode.Properties.Add("Audience", "Users or Groups");             }             navNode.Update();         } }

    Read the article

  • Applying Quotas Across all My Sites

    - by Bil Simser
    Just a quick snippet this morning. If you need to apply a new quota template to all users My Sites here's a quick script to do it. Changing an existing quota is fine but if you're migrating users from another system or you just want to up everyone's storage a bit here's what you do. Create a new quota template. This is found in Central Admin under Application Management | Site Collections | Specify quota templates. There's already a default "Individual Quota" created you might want to create your own or have a special one for your users Open up the PowerShell Management Console and enter "Get-SPWebApplication". This will list all your web applications on the farm.  To apply it to all My Sites (each site is a site collection of its own) run this script below. .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: Consolas, "Courier New", Courier, Monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } 1: $webapps = Get-SPWebApplication; 2:   3: $webapp = $webapps[4]; 4:   5: foreach ($site in $webapp.Sites) { 6: Set-SPSite -Identity $site.url -QuotaTemplate "Your Quota Template" 7: } The first line gets all the web applications on the server. In our case, the forth one is the mysite web app (yours will probably be a different number). Just run Get-SPWebApplication from the console to figure out which one to use. You could get fancy and pipe the name to find it but I'm too lazy for that.Then we loop through all the sites on the list using the $site.url property and pass it to the Set-SPSite cmdlet and specify the name of the our custom QuotaTemplate.Easy. Now all users are updated with the new quota template.

    Read the article

  • Gettings Terms asscoiated to a Specific list item

    - by Gino Abraham
    I had a fancy requirement where i had to get all tags associated to a document set in a document library. The normal tag could webpart was not working when i add it to the document set home page, so planned a custom webpart. Was checking in net to find a straight forward way to achieve this, but was not lucky enough to get something. Since i didnt get any samples in net, i looked into Microsoft.Sharerpoint.Portal.Webcontrols and found a solution.The socialdataframemanager control in 14Hive/Template/layouts/SocialDataFrame.aspx directed me to the solution. You can get the dll from ISAPI folder. Following Code snippet can get all Terms associated to the List Item given that you have list name and id for the list item. using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint; using Microsoft.Office.Server.SocialData; namespace TagChecker { class Program { static void Main(string[] args) { // Your site url string siteUrl = http://contoso; // List Name string listName = "DocumentLibrary1"; // List Item Id for which you want to get all terms int listItemId = 35; using (SPSite site = new SPSite(siteUrl)) { using(SPWeb web = site.OpenWeb()) { SPListItem listItem = web.Lists[listName].GetItemById(listItemId); string url = string.Empty; // Based on the list type the url would be formed. Code Sniffed from Micosoft dlls :) if (listItem.ParentList.BaseType == SPBaseType.DocumentLibrary) { url = listItem.Web.Url.TrimEnd(new char[] { '/' }) + "/" + listItem.Url.TrimStart(new char[] { '/' }); } else if (SPFileSystemObjectType.Folder == listItem.FileSystemObjectType) { url = listItem.Web.Url.TrimEnd(new char[] { '/' }) + "/" + listItem.Folder.Url.TrimStart(new char[] { '/' }); } else { url = listItem.Web.Url.TrimEnd(new char[] { '/' }) + "/" + listItem.ParentList.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url.TrimStart(new char[] { '/' }) + "?ID=" + listItem.ID.ToString(); } SPServiceContext serviceContext = SPServiceContext.GetContext(site); Uri uri = new Uri(url); SocialTagManager mgr = new SocialTagManager(serviceContext); SocialTerm[] terms = mgr.GetTerms(uri); foreach (SocialTerm term in terms) { Console.WriteLine(term.Term.Labels[0].Value ); } } } Console.Read(); } } } Reference dlls added are Microsoft.Sharepoint , Microsoft.Sharepoint.Taxonomy, Microsoft.office.server, Microsoft.Office.Server.UserProfiles from ISAPI folder. This logic can be used to make a custom tag cloud webpart by taking code from OOB tag cloud, so taht you can have you webpart anywhere in the site and still get Tags added to a specifc libdary/List. Hope this helps some one.

    Read the article

  • Opening of the spWeb.ContentTypes gives SOAP Exception 0x80004004

    - by mdi
    Hi everybody! I have the code which going through the sharepoint contenttypes and changes needed field display names. On my local server everything works fine, but on the client side it gives me an error: Microsoft.SharePoint.SPException: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)) --- System.Runtime.InteropServices.COMException (0x80004004): Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)) at Microsoft.SharePoint.Library.SPRequestInternalClass.OpenWebInternal(String bstrUrl, Guid& pguidID, String& pbstrRequestAccessEmail, UInt32& pwebVersion, String& pbstrServerRelativeUrl, UInt32& pnLanguage, UInt32& pnLocale, String& pbstrDefaultTheme, String& pbstrDefaultThemeCSSUrl, String& pbstrAlternateCSSUrl, String& pbstrCustomizedCssFileList, String& pbstrCustomJSUrl, String& pbstrAlternateHeaderUrl, String& pbstrMasterUrl, String& pbstrCustomMasterUrl, String& pbstrSiteLogoUrl, String& pbstrSiteLogoDescription, Object& pvarUser, Boolean& pvarIsAuditor, Int32& plSiteFlags) at Microsoft.SharePoint.Library.SPRequest.OpenWebInternal(String bstrUrl, Guid& pguidID, String& pbstrRequestAccessEmail, UInt32& pwebVersion, String& pbstrServerRelativeUrl, UInt32& pnLanguage, UInt32& pnLocale, String& pbstrDefaultTheme, String& pbstrDefaultThemeCSSUrl, String& pbstrAlternateCSSUrl, String& pbstrCustomizedCssFileList, String& pbstrCustomJSUrl, String& pbstrAlternateHeaderUrl, String& pbstrMasterUrl, String& pbstrCustomMasterUrl, String& pbstrSiteLogoUrl, String& pbstrSiteLogoDescription, Object& pvarUser, Boolean& pvarIsAuditor, Int32& plSiteFlags) --- End of inner exception stack trace --- at Microsoft.SharePoint.Library.SPRequest.OpenWebInternal(String bstrUrl, Guid& pguidID, String& pbstrRequestAccessEmail, UInt32& pwebVersion, String& pbstrServerRelativeUrl, UInt32& pnLanguage, UInt32& pnLocale, String& pbstrDefaultTheme, String& pbstrDefaultThemeCSSUrl, String& pbstrAlternateCSSUrl, String& pbstrCustomizedCssFileList, String& pbstrCustomJSUrl, String& pbstrAlternateHeaderUrl, String& pbstrMasterUrl, String& pbstrCustomMasterUrl, String& pbstrSiteLogoUrl, String& pbstrSiteLogoDescription, Object& pvarUser, Boolean& pvarIsAuditor, Int32& plSiteFlags) at Microsoft.SharePoint.SPWeb.InitWebPublic() at Microsoft.SharePoint.SPWeb.get_ServerRelativeUrl() at Microsoft.SharePoint.SPWeb.get_Url() at Microsoft.SharePoint.SPContentTypeCollection.FetchCollection() at Microsoft.SharePoint.SPContentTypeCollection..ctor(SPWeb web, Boolean bAll) at Microsoft.SharePoint.SPWeb.get_ContentTypes() the code is below: SPWebApplication webApp = SPWebService.ContentService.WebApplications[someGuid]; foreach (SPSite spSite in webApp.Sites) { using (SPWeb spWeb = spSite.RootWeb) { try { foreach (SPContentType spContentType in spWeb.ContentTypes) { ... }}}.. Could anybody provide me with workaround or with the reason of the problem.

    Read the article

  • SharePoint 2010 Hosting :: Setting Default Column Values on a Folder Programmatically

    - by mbridge
    The reason I write this post today is because my initial searches on the Internet provided me with nothing on the topic.  I was hoping to find a reference to the SDK but I didn’t have any luck.  What I want to do is set a default column value on an existing folder so that new items in that folder automatically inherit that value.  It’s actually pretty easy to do once you know what the class is called in the API.  I did some digging and discovered that class is MetadataDefaults. It can be found in Microsoft.Office.DocumentManagement.dll.  Note: if you can’t find it in the GAC, this DLL is in the 14/CONFIG/BIN folder and not the 14/ISAPI folder.  Add a reference to this DLL in your project.  In my case, I am building a console application, but you might put this in an event receiver or workflow. In my example today, I have simple custom folder and document content types.  I have one shared site column called DocumentType.  I have a document library which each of these content types registered.  In my document library, I have a folder named Test and I want to set its default column values using code.  Here is what it looks like.  Start by getting a reference to the list in question.  This assumes you already have a SPWeb object.  In my case I have created it and it is called site. SPList customDocumentLibrary = site.Lists["CustomDocuments"]; You then pass the SPList object to the MetadataDefaults constructor. MetadataDefaults columnDefaults = new MetadataDefaults(customDocumentLibrary); Now I just need to get my SPFolder object in question and pass it to the meethod SetFieldDefault.  This takes a SPFolder object, a string with the name of the SPField to set the default on, and finally the value of the default (in my case “Memo”). SPFolder testFolder = customDocumentLibrary.RootFolder.SubFolders["Test"]; columnDefaults.SetFieldDefault(testFolder, "DocumentType", "Memo"); You can set multiple defaults here.  When you’re done, you will need to call .Update(). columnDefaults.Update(); Here is what it all looks like together. using (SPSite siteCollection = new SPSite("http://sp2010/sites/ECMSource")) {     using (SPWeb site = siteCollection.OpenWeb())     {         SPList customDocumentLibrary = site.Lists["CustomDocuments"];         MetadataDefaults columnDefaults = new MetadataDefaults(customDocumentLibrary);          SPFolder testFolder = customDocumentLibrary.RootFolder.SubFolders["Test"];         columnDefaults.SetFieldDefault(testFolder, "DocumentType", "Memo");         columnDefaults.Update();     } } You can verify that your property was set correctly on the Change Default Column Values page in your list This is something that I could see used a lot on an ItemEventReceiver attached to a folder to do metadata inheritance.  Whenever, the user changed the value of the folder’s property, you could have it update the default.  Your code might look something columnDefaults.SetFieldDefault(properties.ListItem.Folder, "MyField", properties.ListItem[" This is a great way to keep the child items updated any time the value a folder’s property changes.  I’m also wondering if this can be done via CAML.  I tried saving a site template, but after importing I got an error on the default values page.  I’ll keep looking and let you know what I find out.

    Read the article

  • Access denied when trying to read information about SharePoint groups

    - by strongopinions
    I am trying to get the membership of a group in WSS 3.0. I am doing this in an elevated permissions block. Here is the code: SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(SPContext.Current.Site.ID)) { using (SPWeb rootWeb = site.RootWeb) { SPGroup gAdmins = rootWeb.SiteGroups["Admins"]; } } }); I get taken to the "access denied" SharePoint screen when I run this code. The group exists. The identity of the application pool for the web application is in the dbo role in the content database. The code works on my development server, but not on another server, which leads me to believe there is something wrong with the permissions or configuration on this server, maybe something in dcomcnfg? Here are some lines from the SharePoint log that seem to be related: PermissionMask check failed. asking for 0x08000000, have 0x00000000 Unknown SPRequest error occurred. More information: 0x80070005 Access Denied for /Pages/UserAdmin.aspx. StackTrace: Microsoft.SharePoint.Utilities.SPUtility:Void HandleAccessDenied(System.Exception), Microsoft.SharePoint.SPGlobal:Void HandleUnauthorizedAccessException(System.UnauthorizedAccessException), .... [UserAdmin.aspx hosts my custom web part containing the code]

    Read the article

  • Login failed when a web service tries to communicate with SharePoint 2007

    - by tata9999
    Hi, I created a very simple webservice in ASP.NET 2.0 to query a list in SharePoint 2007 like this: namespace WebService1 { /// <summary> /// Summary description for Service1 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class Service1 : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { return "Hello World"; } [WebMethod] public string ShowSPMyList() { string username = this.User.Identity.Name; return GetList(); } private string GetList() { string resutl = ""; SPSite siteCollection = new SPSite("http://localhost:89"); using (SPWeb web = siteCollection.OpenWeb()) { SPList mylist = web.Lists["MySPList"]; SPQuery query = new SPQuery(); query.Query = "<Where><Eq><FieldRef Name=\"AssignedTo\"/><Value Type=\"Text\">Ramprasad</Value></Eq></Where>"; SPListItemCollection items = mylist.GetItems(query); foreach (SPListItem item in items) { resutl = resutl + SPEncode.HtmlEncode(item["Title"].ToString()); } } return resutl; } } } This web service runs well when tested using the built-in server of Visual Studio 2008. The username indicates exactly my domain account (domain\myusername). However when I create a virtual folder to host and launch this web service (still located in the same machine with SP2007), I got the following error when invoking ShowSPMyList() method, at the line to execute OpenWeb(). These are the details of the error: System.Data.SqlClient.SqlException: Cannot open database "WSS_Content_8887ac57951146a290ca134778ddc3f8" requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. Does anyone have any idea why this error happens? Why does the web service run fine inside Visual Studio 2008, but not when running stand-alone? I checked and in both cases, the username variable has the same value (domain\myusername). Thank you very much.

    Read the article

  • Uploading file with metadata

    - by Dilse Naaz
    Hi Could you help me for how to adding a file to the sharepoint document library? I found some articles in net. but i didn't get the complete concept of the same. Now i uploaded a file without metadata by using this code. if (fuDocument.PostedFile != null) { if (fuDocument.PostedFile.ContentLength > 0) { Stream fileStream = fuDocument.PostedFile.InputStream; byte[] byt = new byte[Convert.ToInt32(fuDocument.PostedFile.ContentLength)]; fileStream.Read(byt, 0, Convert.ToInt32(fuDocument.PostedFile.ContentLength)); fileStream.Close(); using (SPSite site = new SPSite(SPContext.Current.Site.Url)) { using (SPWeb webcollection = site.OpenWeb()) { SPFolder myfolder = webcollection.Folders["My Library"]; webcollection.AllowUnsafeUpdates = true; myfolder.Files.Add(System.IO.Path.GetFileName(fuDocument.PostedFile.FileName), byt); } } } } This code is working as fine. But i need to upload file with meta data. Please help me by editing this code if it possible. I created 3 columns in my Document library..

    Read the article

  • How to add a user to a SharePoint group programatically - Access is Denied

    - by Josh
    I have tried and tried to add a user to a SharePoint group using C# programatically (using a non-site admin). If I am logged in as a site admin, it works fine... but, if I am logged in as a non-site admin then I get an access is denied error. After doing some investigation I found that I needed to either "impersonate" the user (which didn't seem to work) or "ensure the user", so I have ended up at this code (which has worked for some people). Can some help explain to me why the following does not work and still gives me an Access is Denied error? SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(SPControl.GetContextSite(HttpContext.Current).Url)) //have also tried passing in the ID - doesn't make a difference { using (SPWeb web = site.OpenWeb()) { web.AllowUnsafeUpdates = true; // add user to group SPGroup group = this.Web.Groups[groupList.Items[i].Value]; SPUser spUser = web.EnsureUser(provider + ":" + user.UserName); //provider is previously defined spUser.Email = user.Email; spUser.Name = txtFullName.Text; group.AddUser(spUser); // update group.Update(); } } }

    Read the article

  • Copy folders when copying list items from source to destination

    - by iHeartDucks
    Hi, This is my code to copy files in a list from source to destination. Using the code below I am only able to copy files but not folders. Any ideas on how can I copy the folders and the files within those folders? using (SPSite objSite = new SPSite(URL)) { using (SPWeb objWeb = objSite.OpenWeb()) { SPList objSourceList = null; SPList objDestinationList = null; try { objSourceList = objWeb.Lists["Source"]; } catch(Exception ex) { Console.WriteLine("Error opening source list"); Console.WriteLine(ex.Message); } try { objDestinationList = objWeb.Lists["Destination"]; } catch (Exception ex) { Console.WriteLine("Error opening destination list"); Console.WriteLine(ex.Message); } string ItemURL = string.Empty; if (objSourceList != null && objDestinationList != null) { foreach (SPListItem objSourceItem in objSourceList.Items) { ItemURL = string.Format(@"{0}/Destination/{1}", objDestinationList.ParentWeb.Url, objSourceItem.Name); objSourceItem.CopyTo(ItemURL); objSourceItem.UnlinkFromCopySource(); } } } } Thanks

    Read the article

  • EF + UnitOfWork + SharePoint RunWithElevatedPrivileges

    - by Lorenzo
    In our SharePoint application we have used the UnitOfWork + Repository patterns together with Entity Framework. To avoid the usage of the passthrough authentication we have developed a piece of code that impersonate a single user before creating the ObjectContext instance in a similar way that is described in "Impersonating user with Entity Framework" on this site. The only difference between our code and the referred question is that, to do the impersonation, we are using RunWithElevatedPrivileges to impersonate the Application Pool identity as in the following sample. SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(url)) { _context = new MyDataContext(ConfigSingleton.GetInstance().ConnectionString); } }); We have done this way because we expected that creating the ObjectContext after impersonation and, due to the fact that Repositories are receiving the impersonated ObjectContext would solve our requirement. Unfortunately it's not so easy. In fact we experienced that, even if the ObjectContext is created before and under impersonation circumstances, the real connection is made just before executing the query, and so does not use impersonation, which break our requirement. I have checked the ObjectContext class to see if there was any event through which we can inject the impersonation but unfortunately found nothing. Any help?

    Read the article

  • How can I tell whether a webpart that has been deployed to a site is a native webpart that ships wit

    - by program247365
    I have a SharePoint 2007 MOSS instance, and I'm on a fact-finding mission. There have been multiple developers, developing multiple webparts and deploying them (using VS2005/2008 SharePoint Extensions). I thought maybe I could look at the fields in the "Web Part Gallery" list in my site, and look by "Modified by", but it looks like a developer's name is on some of the out-of-the-box webparts somehow, and on ones I know are custom developed, they say "System Account" - so looking at that field in this list is a no go. I thought then maybe I could look at the "Group" to which each webpart was assigned but it looks like they were arbitrarily assigned to many different groups inconsistently - so using that piece of information is a no go. Here is my code I have for just looping through and getting the names of all the webparts. Is there any property I can access on the list items of webparts that would tell me whether it's a custom developed webpart? Any way to distinguish the custom webparts from the out-of-the-box ones? Is there another way to do this? #region Misc Site Collection Methods public static List<string> GetAllWebParts(string connectedSPInstanceUrl) { List<string> lstWebParts = new List<string>(); try { using (SPSite site = new SPSite(connectedSPInstanceUrl)) { using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists["Web Part Gallery"]; foreach (SPListItem item in list.Items) { lstWebParts.Add(item.Name); } } } } catch (Exception ex) { lstWebParts.Add("Error"); lstWebParts.Add("Message: " + ex.Message); lstWebParts.Add("Inner Exception: " + ex.InnerException.ToString()); lstWebParts.Add("Stack Trace: " + ex.StackTrace); } return lstWebParts; } #endregion

    Read the article

  • How to Create a Folder in the Current Document Library if it's not already present?

    - by Rosh Malai
    All I want to do is to create a folder "MetaFolder" inside a document library. User can be on any document library and I would like to create this folder after item is added (so on itemAdded event handler). I do NOT want workflow so please dont suggest workflow. This code works but I have to hardcode the url but need to get url from current url. also need to verify the folder uHippo does not exists in the current doc library... public override void ItemAdded(SPItemEventProperties properties) { base.ItemAdded(properties); using (SPSite currentSite = new SPSite(properties.WebUrl)) using (SPWeb currentWeb = currentSite.OpenWeb()) { // This code works and creates Folder in the "My TEST Doc library" //SPList docLib = currentWeb.Lists["My TEST Doc Library"]; //SPListItem folder = docLib.Folders.Add(docLib.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, "My folder"); //folder.Update(); string doclibname = "Not a doclib"; //SPList doclibList = currentWeb.GetList(HttpContext.Current.Request.RawUrl); // NOT WORKING. Tried properties.weburl SPList doclibList = currentWeb.GetListFromUrl("https://mycompanyportal/sites/testsitecol/testwebsite/My%20TEST%20Doc%20Library/Forms/AllItems.aspx"); if (null != doclibList) { doclibname = doclibList.Title; } // this section also not working. // getting Object reference not set to an instance of an object or something like that. //if (currentWeb.GetFolder("uHippo").Exists == false) //{ SPListItem folder = doclibList.Folders.Add(doclibList.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, "uHippo"); folder.Update(); //} } }

    Read the article

  • 1. Get the Current Document Library 2. Create a Folder "MetaFolder" if it's not already present

    - by Rosh Malai
    All I want to do is to create a folder "MetaFolder" inside a document library. User can be on any document library and I would like to create this folder after item is added (so on itemAdded event handler). I do NOT want workflow so please dont suggest workflow. This code works but I have to hardcode the url but need to get url from current url. also need to verify the folder uHippo does not exists in the current doc library... Thanks public override void ItemAdded(SPItemEventProperties properties) { base.ItemAdded(properties); using (SPSite currentSite = new SPSite(properties.WebUrl)) using (SPWeb currentWeb = currentSite.OpenWeb()) { // This code works and creates Folder in the "My TEST Doc library" //SPList docLib = currentWeb.Lists["My TEST Doc Library"]; //SPListItem folder = docLib.Folders.Add(docLib.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, "My folder"); //folder.Update(); string doclibname = "Not a doclib"; //SPList doclibList = currentWeb.GetList(HttpContext.Current.Request.RawUrl); // NOT WORKING. Tried properties.weburl SPList doclibList = currentWeb.GetListFromUrl("https://mycompanyportal/sites/testsitecol/testwebsite/My%20TEST%20Doc%20Library/Forms/AllItems.aspx"); if (null != doclibList) { doclibname = doclibList.Title; } // this section also not working. // getting Object reference not set to an instance of an object or something like that. //if (currentWeb.GetFolder("uHippo").Exists == false) //{ SPListItem folder = doclibList.Folders.Add(doclibList.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, "uHippo"); folder.Update(); //} } }

    Read the article

  • Accessing a share point site using the object model.

    - by Prashanth
    Hi I am trying to access a share point site using the SP object model from a console application. I am trying to do something like this.. SPSite site = new SPSite(sitePath) //Operations go here This works fine when the share point site and the console app are on the same machine. However when the console app and the site are on different machines, I get an error "The Web application at "http://server/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" Here are the things that I have already done: 1) I have tried accessing the site via both IP address as well as machine name, assuming that it could be a DNS resolution issue. 2) Initially I impersonated using a farm admin account, still i could not access. Then I added myself as the farm admin, still no joy. 4) The site is accessible via IE. So it is not a permission issue I guess. 5) I have tried almost all the solutions suggested by various links obtained by googling the error message. I am trying this on share point 2010. A similar issue occurs on 2007 also. Sometimes its kind of frustrating to do SharePoint development , since I get the feeling of stumbling from one error to the next, with no clue as to what could be wrong and the error messages not being helpful in the least :(

    Read the article

  • Sharepoint 2010 moving site collection to different database error

    - by Brandon Ulasiewicz
    I am trying to move a site collection from one content database to another content database. First I used the following PowerShell command: New-SPContentDatabase -Name New_DB -WebApplication http://portal/ I confirmed that this did in fact create the DB in the SQL Server. I then used the following command: Move-SPSite http://portal/sites/hr -DestinationDatabase New_DB This generates an error stating that the "Operation is not valid due to the current state of the object" Can anyone help point me in the right direction with this? Thanks

    Read the article

< Previous Page | 1 2 3 4  | Next Page >