문제

I'm making an ASMX web method call that contains the following code...It ultimately adds a new item to a sharepoint list

            string spsite = "http://site/subsite";


            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite objSite = new SPSite(spsite))
                {
                    using (SPWeb oweb = objSite.OpenWeb())
                    {
                        oweb.AllowUnsafeUpdates = true;
                        SPList list = oweb.Lists["List"];
                        SPListItem item = list.Items.Add();
                        item["col1"] = "test";
                        item["col2"] = "test";                                          

                        item.Update();

                    }
                }

            });

However, I get the following error messages...

You do not have permission to view this directory or page using the credentials that you supplied

Why is this? I thought RunWithElevatedPrivileges does away with this?

도움이 되었습니까?

해결책

Where is this web service hosted? Using RunWithElevtatedPrivileges will use the account that the app pool runs on. If the app pool does not have permission, then you will get access denied.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top