In my scenario, I had to write to a file through an existing COM Component via a .NET COM Interop library. It depended on the write operation being done from the context of a valid user - otherwise the file wouldn't be stamped correctly with author metadata.
To do this, I had to use an overload of the WindowsIdentity constructor which accepts a UPN (User Principal Name). From there, you can impersonate users within your code at will.
NOTE: the account that is doing the impersonation (e.g. svcSP) will need to have the "Act as Part of the Operating System" right as defined in your Local User Policy for this to work.
Code Sample:
void Main() { var userName = "LOCALDEV\\david.klein"; PrincipalContext ctx = new PrincipalContext(ContextType.Domain); var user = UserPrincipal.FindByIdentity(ctx, userName); if (user != null) { var upn = user.UserPrincipalName; Debug.Print(upn); WindowsIdentity id = new WindowsIdentity(upn); WindowsImpersonationContext wic = id.Impersonate(); try { // Do what you need here under the impersonation context. var currentId = WindowsIdentity.GetCurrent().Name; Debug.Print(currentId); } finally { wic.Undo(); } } }
47 comments:
Your content is awesome . You have done a great job and its very useful for me . I appreciate your effort and I hope that you will get more positive comments from the web users.
SMO Services Chennai
Got a creative information. Understand well in this. This gives the easy technique of experiment. New technologies are developed more. so techniques are also improved. Thank you for this information.
Digital Marketing Company in Chennai
Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..
iOS Training in Chennai
Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us.
Best Dental Clinic In Velachery
Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every
blog.. i am expecting more updated posts from your hands.
Android App Development Company
mobile App Development Company
I am expecting more interesting topics from you. And this was nice content and definitely it will be useful for many people.
iOS App Development Company
iOS App Development Company
These ways are very simple and very much useful, as a beginner level these helped me a lot thanks fore sharing these kinds of useful and knowledgeable information.
Fitness SMS
Fitness Text
Salon SMS
Salon Text
Investor Relation SMS
Investor Relation Text
great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
web design Company
web development Company
web design Company in chennai
web development Company in chennai
web design Company in India
web development Company in India
it is really amazing...thanks for sharing....provide more useful information...
Mobile app development company
it is really amazing...thanks for sharing....provide more useful information...
Mobile app development company
Get Details of Flooring Tiles Manufacturers And Dealers. ... Heat Resistance Tiles, Heat Resistant Terrace Tiles. Thanks you for sharing
tile bonder manufacturer in delhi
Lifestyle Magazine India; Lifestyle is a elite magazine circulated to the elite at page parties. Lifestyle Magazine also circulated to the elite at clubs, lounge bars etc.
Lifestyle Magazine
hi, nice information is given in this blog. Thanks for sharing this type of information, it is so useful for me. nice work keep it up.
digital marketing company in delhi
nice topic which you have choose.
second is, the information which you have provided is better then other blog.
so nice work keep it up. And thanks for sharing.
Epoxy Grout manufacturer in delhi
Laminated Doors manufacturer in hubli
hi, nice information is given in this blog. Thanks for sharing this type of information, it is so useful for me. nice work keep it up. led lawn lights in delhi
All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.
Java training in Pune
Java interview questions and answers
Java training in Chennai | Java training institute in Chennai | Java course in Chennai
Java training in Bangalore | Java training institute in Bangalore | Java course in Bangalore
This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me..
python course in pune
python course in chennai
python course in Bangalore
Thanks for such a great article here. I was searching for something like this for quite a long time and at last I’ve found it on your blog. It was definitely interesting for me to read about their market situation nowadays.
Data Science course in Chennai | Best Data Science course in Chennai
Data science course in bangalore | Best Data Science course in Bangalore
Data science course in pune | Data Science Course institute in Pune
Data science online course | Online Data Science certification course-Gangboard
Data Science Interview questions and answers
Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…
Best Devops training in sholinganallur
Devops training in velachery
Devops training in annanagar
Devops training in tambaram
I appreciate your efforts because it conveys the message of what you are trying to say. It's a great skill to make even the person who doesn't know about the subject could able to understand the subject . Your blogs are understandable and also elaborately described. I hope to read more and more interesting articles from your blog. All the best.
rpa training in Chennai | rpa training in bangalore | best rpa training in bangalore | rpa course in bangalore | rpa training institute in bangalore | rpa training in bangalore | rpa online training
Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
angularjs interview questions and answers
angularjs Training in bangalore
angularjs Training in bangalore
angularjs interview questions and answers
angularjs Training in marathahalli
angularjs interview questions and answers
شركة مكافحة حشرات بنجران
Thanks for sharing this blog, this blog is very helpful information for every one.
Mobile app Development Company in Noida
Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you.
Keep update more information..
Selenium training in bangalore
Selenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune
Selenium Online training
Selenium interview questions and answers
Read all the information that i've given in above article. It'll give u the whole idea about it.
microsoft azure training in bangalore
rpa training in bangalore
best rpa training in bangalore
rpa online training
شركة تنظيف بالدمام
شركة تركيب كهرباء بالدمام
شركة تمديد و صيانة برك مسابح بالدمام
Thanks for the article may be useful for everything
App Developers in Noida
Mobile app development company in Canada
Thanks for sharing valuable Information, I really very impressive on your blog. I hope you continue on blogging job.
Mobile App Development Company in Mumbai
Thanks for sharing this quality information with us. I really enjoyed reading.
Deer Hunting Tips Camping Trips Guide DEER HUNTING TIPS travel touring tips
thanks for posting this blog. its really very helpful for us.
Still Hunting Method
Hunting psych tips Survival Tips Travel Touring Tips
Well thanks for the information, do not forget to visit my blog too.
travel trekking tips
see the link Tent Camping 101 Exploring Smithriver
Your very own commitment to getting the message throughout came to be rather powerful and have consistently enabled employees just like me to arrive at their desired goals.
Data science Course Training in Chennai | Data Science Training in Chennai
RPA Course Training in Chennai | RPA Training in Chennai
AWS Course Training in Chennai | AWS Training in Chennai
Wow, amazing blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your website is fantastic, let alone the content!
3d animation Company
Best Chatbot Development Company
Mobile app development in Coimbatore
Mobile app development company in mumbai
Consistently learning the new skills and using them to improve myself in the form of performance for betterment.
Thanks
Cpa offers
The blog was absolutely fantastic! Lot of great information which can be helpful in some or the other way. Keep updating the blog. We are top CRM Software.
It’s great to come across a blog every once in a while that isn’t the same out of date rehashed material. Fantastic read.
Data science Course Training in Chennai |Best Data Science Training Institute in Chennai
You have a real ability for writing unique content. I like how you think and the way you represent your views in this article. We are Best CRM Software in Mumbai.
If handling your academic obligations seems hard consider Essay Writing Help Services from professionals for your Custom Essay Writing Services and Legitimate Custom Writing Services.
data science course bangalore is the best data science course
Wow it is really wonderful and awesome thus it is veWow, it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot.
oracle dba training in bangalore
oracle dba courses in bangalore
oracle dba classes in bangalore
oracle dba training institute in bangalore
oracle dba course syllabus
best oracle dba training
oracle dba training centers
This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points. To appreciate this I like to share some useful information.
perl training institutes in bangalore
perl training in bangalore
best perl training institutes in bangalore
perl training course content
perl training interview questions
perl training & placement in bangalore
perl training center in bangalore
It is very good and useful for students and developer.Learned a lot of new things from your post Good creation,thanks for give a good information at sap crm.
mysql dba training in bangalore
mysql dba courses in bangalore
mysql dba classes in bangalore
mysql dba training institute in bangalore
mysql dba course syllabus
best mysql dba training
mysql dba training centers
I have to voice my passion for your kindness giving support to those people that should have guidance on this important matter.
pega training institutes in bangalore
pega training in bangalore
best pega training institutes in bangalore
pega training course content
pega training interview questions
pega training & placement in bangalore
pega training center in bangalore
Excellent post for the people who really need information for this technology.
sql server dba training in bangalore
sql server dba courses in bangalore
sql server dba classes in bangalore
sql server dba training institute in bangalore
sql server dba course syllabus
best sql server dba training
sql server dba course syllabus
best sql server dba training
sql server dba training centers
Post a Comment