In an open-source software project, GPL2 or 3, is it legal to use code snippets from Microsoft Knowledge Base articles - the ones that used to be called something like Q1234567, nowadays called just by the number, say 1234567?
Let me take a practical example with this article on How to recursively search directories by using Visual C# that contains some sizeable code snippets. Is there any indication of what I can do with its code snippets?
At the bottom of the article there is an explicit copyright notice
Unless otherwise specified, the Services are for your personal and non-commercial use. You may not modify, copy, distribute, transmit, display, perform, reproduce, publish, license, create derivative works from, transfer, or sell any information, software, products or services obtained from the Services.
I could not find anything else that would specify otherwise in the TOU or the article. Therefore I cannot do much if anything: these terms are conflicting with most open source and proprietary licenses in general and the GPL in particular.
On the TOU page, the "Intellectual Property" menu bar has a link to another Copyrights/Permission page that essentially restates the same thing.
So for KB articles, the answer is: No, I cannot reuse code snippets for inclusion with any software: only some personal limited use is kind of allowed.
In contrast, the MSDN web site TOU are different and called "Microsoft Developer Services Agreement". They have an explicit open source license grants for code samples:
Microsoft Limited Public License
This license governs use of code marked as “sample” or “example” available on this web site without a license agreement, as provided under the section above titled “NOTICE SPECIFIC TO SOFTWARE AVAILABLE ON THIS WEB SITE.” If you use such code (the “software”), you accept this license. If you do not accept the license, do not use the software.
So I may be able to reuse MSDN code samples under this license... but this license is not a true free or open source license because of some restriction and probably other terms:
(F) Platform Limitation - The licenses granted in sections 2(A) and 2(B) extend only to the software or derivative works that you create that run on a Microsoft Windows operating system product.
The license only applies to Windows-based software so it is as bad as a proprietary agreement for use in any open source-licensed software.
Would the answer here change in any way if the said article were an old one, no longer updated by Microsoft, as in "This article has been archived. It is offered "as is" and will no longer be updated"?
Let's again take a concrete example with this article:
This article has been archived. It is offered "as is" and will no longer be updated.
The fact it is no longer updated has no impact for now until the copyright expires in a 100 years or so e.g. 50 to 70 years after the author (Microsoft? or one of its employees?) dies... :
In most countries, the duration of copyright is dependent on the duration of the author's life. After he dies, his estate can exercise the copyright for at least 50 more years. In most countries, the term is even longer: 70 years after the author's death.
So this statement has no practical impact for the time being. If I feel very strongly about this code snippet I could contact Microsoft to ask them for different license terms. Good luck!
Very short snippet (especially if you modify it, to prove that you copied the idea not a code that you don't understand) and idea are not copyright-able, so you can reuse it.
But for larger code, you cannot use the code (see the other answer).
Note: once you find the solution, you can look for other sites which use similar code (on non Microsoft sites, with better licenses), or just apply the idea you just learned (maybe after a day, without looking again the original site).