Sunday, January 25, 2009

Anyone know where I can find a good Locksmith?

I recently had the need to develop a WebPart for a client that needed to be able to "unlock" a site collection. For any of you that have tried this from within a WebPart running on the SharePoint platform, you know there are quite a few issues that can come up.

There are four different types of locks that can be set, here is a quick mapping of how those locks match up with the SPSite locking properties:

Not locked / nonesite.writeLocked = false
site.readOnly = false
site.readLocked = false
Adding content prevented / noadditionssite.writeLocked = true
site.readOnly = false
site.readLocked = false
Read-only / readonlysite.writeLocked = false
site.readOnly = true
site.readLocked = false
No access / noaccesssite.writeLocked = false
site.readOnly = false
site.readLocked = true

Additionally, when a site is locked using any one of the lock options, the site.LockIssue is used to describe the reason for the lock. If the site was locked using the Central Administraion console, the Additional lock information (LockIssue) field is required when locking the site. However, this parameter is not set when locking a site using the command line interface stsadm.

Here are just a few of the error messages I ran into while trying to set the lock options outright in my WebPart:
  1. Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb.
  2. The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
  3. Access to this Web site has been blocked.
  4. Attempted to perform an unauthorized operation.
  5. Access denied.
With the exception of the first error, the remainder of the messages all center around permissions and access. With that in mind, I went about trying to build some solutions using the typical SharePoint methods to elevate the privileges of the code being executed. The first of these is the SPSecurity.RunWithElevatedPrivileges. With impersonation turned on in our web.config file, the code is running under the context of the SharePoint user. This method appears to elevate the code to run under the service account on the application pool.
using (SPSite site = new SPSite(siteUrl))
site.AllowUnsafeUpdates = true;
site.ReadLocked = false;
site.ReadOnly = false;
site.WriteLocked = false;
site.LockIssue = "";
Next, with no more luck, I tried to initialize a instance of the site class running under the context of my administration account.
using (SPSite site = new SPSite(siteUrl, SPContext.Current.Web.AllUsers["domain\\adminUsername"].UserToken))
site.AllowUnsafeUpdates = true;
site.ReadLocked = false;
site.ReadOnly = false;
site.WriteLocked = false;
site.LockIssue = "";
After a little bit more investigating, I discovered that in order to perform the unlock procedures that I needed, full blown code impersonation was needed. With a little bit of additional code, I had the access that I needed.
//get global admin access to perform the work
ImpersonateValidUser("domain", "adminUsername", "password");

using (SPSite site = new SPSite(siteUrl))
site.WebApplication.FormDigestSettings.Enabled = false;
site.AllowUnsafeUpdates = true;
site.ReadLocked = false;
site.ReadOnly = false;
site.WriteLocked = false;
site.LockIssue = "";

The code to implement the ImpersonateValidUser and UndoImpersonation functions can be found here:, a wonderful bit of code from Uwe Keim.

By adding the line site.WebApplication.FormDigestSettings.Enabled = false to the code, we are able circumvent error #2. All of the remaining errors should be taken care of by our code impersonation. However, be warned that if the site has either readOnly or readLocked set to true, you will still have issues accessing values of various site properties. You will need to unlock the site to get the values that you need. If desired, you can then set the locks back to their previous state (assuming you have saved the state somewhere). And yes, you will even run into errors simply trying to save off this state for later use. The specific type of error that gets thrown will tell you everything you need to know about which of the three locks has been set.

When implementing the code, be sure that it is not executing when the page initially loads, otherwise you will run into error #1. Rather run the code during a page post back (i.e. in an event handler to manage the WebPart form submittal).


Anonymous said...

Auto locksmith Indianapolis is centrally located and local for fast 24hr response. Car locksmith in Indianapolis is licensed and insured. indianapolis auto locksmith

Anna Schafer said...

If you locked your keys in the car, call Unlock Indy LLC at 317-590-2842. Our helpful car locksmith in Indianapolis will retrieve the keys quickly.

Elizabeth J. Neal said...

Here are just a few of the error messages I ran into while trying to set the lock options outright in my WebPart: indianapolis mobile locksmith

Elizabeth J. Neal said...

Additionally, when a site is locked using any one of the lock options, the site.LockIssue is used to describe the reason for the lock. If the site was locked using the Central Administraion console, the Additional lock information (LockIssue) field is required when locking the site. However, this parameter is not set when locking a site using the command line interface stsadm. locksmith indianapolis

Elizabeth J. Neal said...

The Locksmiths Guild of Australia is a trade association which provides a range of services and support to its members.

Yellow Blade said...

Công ty vận chuyển hàng hóa nội địa chúng tôi xin giới thiệu các dịch vụ vận chuyển, dịch vụ ship hàng uy tín để phục vụ nhu cầu Tết của quý khách hàng. Cụ thể chúng tôi sẽ cung cấp dịch vụ chuyển quà tết. Chúng tôi sẽ giúp bạn vận chuyển hàng hóa đến tay người thân, bạn bè ở xa một cách nhanh chóng nhất. Đảm bảo giá cả hợp lý chất lượng dịch vụ tuyệt vời. Ngoài ra chúng tôi còn cung cấp nhiều dịch vụ khác như dịch vụ ship hàng cod, giao hàng cho shop, dịch vụ chuyển phát nhanh trong nước,... Nếu cần chuyển hàng hãy nhớ liên hệ với chúng tôi nhé.

Lisa Jones said...

Furthermore, when a site is bolted utilizing any of the lock choices, the site.LockIssue is utilized to depict the purpose behind the lock. On the off chance that the site was bolted utilizing the Central Administraion support, the Additional lock data (LockIssue) field is required when bolting the site. Be that as it may, this parameter is not set when bolting a site utilizing the charge line interface..
locksmith in kirkland

Unknown said...

Guys, sorry that it is off-topic, but I'm looking for a good locksmith. Urgently! Can someone help me with it? What can you tell about them? I really appreciate it!

Unknown said...

Guys, do you know what is the price for lock replacing? I would like to compare prices before calling a locksmith

Richard C. Lambert said...

Here are just a few of the error messages I ran into while trying to set the lock options outright in my WebPart. flat rate lock n key las vegas

Unknown said...

If you answered no to any of these questions, it may prove useful to you to look up other locksmiths and compare their locksmith services, emergency locksmith services, security services, and general business history and reputation. Of all the people who you depend on, the person providing you with locksmith services should be among the most trusted. They see what you have inside your home or office, and they know how to get in quickly and easily. It wouldn't do to have your locksmiths services combined with his cat burglar skills to rip you off. 24 hour locksmith denver

Keep in mind that locksmith services are only as good and reliable as the locksmith performing those services. Make sure you find the best available locksmith for all your locksmith service, emergency locksmith service, or security service needs. Don't forget to check into the background of your locksmith carefully as well. I recommend that you always check the Better Business Bureau for history of complaints, but even better would be to use their website as a starting point for your search. Then you'll know that the locksmith services you're using are compliant with their standards, and can be trusted.

historypak said...

thank you for your interesting infomation. TONY"S LOCKSMITH BAY DR at COLLOQUIS

Anna Schafer said...

Personally I think overjoyed I discovered the blogs.
locksmith las vegas

Anna Schafer said...

It’s good to check this kind of website. I think I would so much from you.
Car Lockout Commerce City

Doke said...

To jowdjbrown

Check this interesting it's helps you understand more about locksmiths history!

historypak said...

Hello I am so delighted I located your blog, I really located you by mistake, while I was watching on google for something else, Anyways I am here now and could just like to say thank for a tremendous post and a all round entertaining website. Please do keep up the great work. nationale slotenmaker antwerpen

Unknown said...

Là 1 công ty Uy Tín – Đáng Tin Cậy. sở hữu nhiều năm kinh nghiệm trong lĩnh vực chi phí. Chúng tôi luôn đặt “Lời ích quý khách khi vay tiền lên hàng đầu”. Sau thoáng đãng năm phát triễn nghiên cứu. nhận diện được sự phiền toái và thủ tục rượm rà lúc vay tiền bây giờ. nên chúng tôi đưa ra giải pháp mới phù hợp sở hữu khuynh hướng mới Vay tiền mặt – có tiền nhanh trong ngày.

1. Thủ tục vay đơn thuần nhất hiện giờ
Chỉ nên giấy tờ không buộc phải giám định rườm rà. Bằng tài xế hoặc Hộ khẩu đã vay được tiền.
2. thời gian giải ngân tiền mặt nhanh nhất hiện thời
Cam kết xem xét hồ sơ trong 15 – 30 phút. Giải ngân tiền mặt sau 30 phút – tới 2h trường hợp khiến giấy tờ trước 21H Tối. Chúng tôi cam kết giải quyết trong ngày. ko để tồn sang hôm sau.
3. Vay toền online miễn là bạn có mạng internet
đa số khi số đông nơi. xem xét website. Chúng tôi sẽ mang chuyên viên tham vấn nhiều năm kinh nghiệm hỗ trợ bạn. Bạn không bắt buộc phải đi xa chờ đợi. Chỉ nhu cầu nhấc máy và gọi. Sẽ vay được tiền.
4. không hề tài sản bảo đảm, chẳng phải chứng tỏ thu nhập
Chỉ đề nghị thủ tục giản đơn như trên. Chúng tôi không buộc phải ai bảo lãnh khoản vay cho bạn. nên cực kỳ yên ổn tâm không làm cho phiền người nhà bạn.

vay tien nhanh, vay tiền nhanh, vay tiền online, vay tien online, vay tien, vay tiền, vay tien, vay tín chấp, vay tin chap, vay tiền nhanh nhất, vay tien nhanh online, vay tiền nhanh online, vay tiền online nhanh, vvay tien online nhanh,
vay tien nhanh nhat,

Rumi said...

I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.
National 7-Eleven Day

Angelica Rose said...

Thank you very much for writing such an interesting article on this topic. This has really made me think and I hope to read more. Secrailway's locksmiths

albina N muro said...

i love reading this article so beautiful!!great job! gt locksmith

gunardi said...

I feel this is among the such a lot vital info for me. And i am satisfied studying your article. However wanna commentary on few general things, The website style is ideal, the articles is truly nice
Tangki Panel

fortnite said...

Cheap locksmith services suffer from the problem of plenty, ironically Unlock Car

Eliza said...

Wow i can say that this is another great article as expected of this blog.Bookmarked this site.. locksmith Tucson Arizona

mtom00000 said...

Interesting website, i read it but i still have a few questions. shoot me an email and we will talk more becasue i may have an interesting idea for you. facebook

nasionalqq said...

Needed to compose you a tiny note to finally thank you very much yet again for your personal splendid methods you have discussed above. It is strangely open-handed with people like you to provide publicly all that a number of people would have marketed as an electronic book to generate some bucks for their own end, primarily now that you could possibly have tried it if you ever wanted. These inspiring ideas likewise acted like a fantastic way to know that the rest have the same dreams really like my personal own to see a whole lot more concerning this problem. I’m sure there are thousands of more enjoyable times in the future for many who check out your blog. London Locksmith

jackman10 said...

Great post, I conceive website owners should learn a lot from this web blog its rattling user genial . car key replacement london

Tom said...

I like this post, I think webs need to learn from you how to wright. this web is wonderful too
locksmith scarborough - Vận tải Con thoi said...

Cảm ơn bạn đã chia sẻ, nếu cần vận tải bắc nam thì a/c liên hệ bên mình nhé. Hotline: 0903751981

RKNSEO said...

Ik heb het helemaal gelezen en ik heb echt genoten van deze complete en uitgebreide inhoud.

Voor alle website design services kunt u contact opnemen met Nexoz.


Uw website moet een identiteit hebben. Uw webontwerp moet de overtuigingen en waarden van uw bedrijf weerspiegelen.

Deny2deny said...

بسیار محتوای مفیدی بود. ممنون از اینکه این گونه مطالب رو به اشتراک می گذارید.

هنگامی که نوبت به یافتن یک شرکت تعمیر لوازم خانگی می رسد، دو سوت تعمیر کلیه شرایط را دارد.

ما اطمینان حاصل می کنیم که فقط از افراد متخصص و واجد شرایط استفاده کنید که می توانید به آنها وابسته باشید.

ما با ارائه ضمانت در کلیه قطعات و تعمیرات در پشت متخصصان خود ایستاده ایم.

هنگامی که دو سوت تعمیر را برای سرویس و یا تعمیر لوازم منزل خود انتخاب می کنید، کاری می کنیم که از تصمیم خود اطمینان داشته باشید.

Deny2deny said...

متشکریم از به اشتراک گذاری.

در صورت نیاز به خدمات طراحی گرافیک، تبلیغات و یا طراحی و توسعه می توانید به تیم ریوال ایجنسی اعتماد کنید.

مهمترین هدف مجموعه ریوال ایجسنی تامین نیازهای قسمت های مختلف گرافیکی و تبلیغاتی در سطح بین الملل در داخل کشور می باشد.

ریوال ایجنسی با سابقه ای درخشان و با در اختیار داشتن کادری مجرب و حرفه ای در عرصه گرافیک و تبلیغات آماده همکاری با شرکت های داخلی و خارجی می باشد.

rampage said...

در صورت نیاز به خدمات طراحی لوگو در تیم خلاق ریوال آنلاین بهترین گزینه ی شما است.

RKNSEO said...

لوگو با بیان خلاقانه مفهوم برند، تعامل مشتری را فراهم می کند.

ایجاد لوگوی خلاقانه با پنهان کردن مفهوم برند در لایه‌های طراحی لوگو و رنگ‌ها، برند شما را بدون زحمت و به سادگی وادار می‌کند، رهبری را از دیگران ربوده و در حالی که در ناخودآگاه مخاطب قرار می‌گیرد، سود را تضمین می‌کند.