<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>weitlandt. &#187; Dokumente exportieren</title>
	<atom:link href="http://weitlandt.com/tags/dokumente-exportieren/feed/" rel="self" type="application/rss+xml" />
	<link>http://weitlandt.com</link>
	<description></description>
	<lastBuildDate>Thu, 06 May 2010 08:56:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Dokumente einfach aus Sharepoint 2001 und 2003 extrahieren</title>
		<link>http://weitlandt.com/theme/2009/11/dokumente-aus-sharepoint-2001-und-2003-extrahieren/</link>
		<comments>http://weitlandt.com/theme/2009/11/dokumente-aus-sharepoint-2001-und-2003-extrahieren/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 15:35:00 +0000</pubDate>
		<dc:creator>ks</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[2003 Server]]></category>
		<category><![CDATA[Dokumente exportieren]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[sps]]></category>
		<category><![CDATA[W2K Server]]></category>

		<guid isPermaLink="false">http://weitlandt.com/?p=140</guid>
		<description><![CDATA[Werkzeuge für die Microsoft Sharepoint Portal Server (SPS) gibt es viele: Ausgefeilte, durchdachte, professionelle usw. Für die einfache Aufgabe, einen Dokumentenbaum auszulesen, genügen Grundkenntnisse der Struktur und ein paar Zeilen Programmcode. Wir betrachten im folgenden die beiden ersten Versionen von Microsoft Sharepoint Server, also 2001 und 2003: Exportieren mit einer einzigen Zeile Shellscript: Sharepoint Portal [...]]]></description>
			<content:encoded><![CDATA[<p>Werkzeuge für die <strong>Microsoft Sharepoint Portal Server</strong> (SPS) gibt es viele: Ausgefeilte, durchdachte, professionelle usw. Für die einfache Aufgabe, einen Dokumentenbaum auszulesen, genügen Grundkenntnisse der Struktur und ein paar Zeilen Programmcode. Wir betrachten im folgenden die beiden ersten Versionen von Microsoft Sharepoint Server, also 2001 und 2003:</p>
<h3>Exportieren mit einer einzigen Zeile Shellscript: Sharepoint Portal Server 2001</h3>
<p><span>Der SPS 2001 war für die <strong>Windows 2000 &#8211; Serverumgebung</strong> zugeschnitten; schon unter Windows 2003 Server läuft er nicht mehr. Microsoft hat aber neben HTTP und DAV einen Zugang per IFS (installable file system) vorgesehen, um lesenden Zugriff auf die Dokumentenstruktur eines Arbeitsbereichs zu erhalten. Das gleiche Verfahren wird übrigens auch noch von Exchange 2000 angewandt, sodaß man durch die &#8220;Hintertür&#8221; Zugriff auf die Dateistrukturen hat. </span><br />
<span>Mit diesem Shell-Kommando auf dem W2K-Server selbst (via cmd.exe) wird ein Laufwerksbuchstabe zugeordnet:<br />
</span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
subst M: \\.\backofficestorage</pre></div></div>

<p><span>Arbeitet man mit dem Windows-Explorer, müssen <em>versteckte Ordner und Dateien</em> angezeigt werden, sonst sieht man den Ordner <strong><em>WORKSPACES</em> </strong>nicht, der die eigentlichen Dateien enthält; der Arbeitsbereich  <strong><em>TESTDOCS</em> </strong>unter <strong>&#8220;Anwendungen&#8221;</strong> ist leer (Dokumentenverzeichnis grün markiert)<br />
</span></p>
<p><a href="http://weitlandt.com/media/files/explorer-sharepoint2001.jpg"><img class="alignright size-full wp-image-150" title="explorer-sharepoint2001" src="http://weitlandt.com/media/files/explorer-sharepoint2001.jpg" alt="explorer-sharepoint2001" width="284" height="188" /></a></p>
<p>Eine Zusammenfassung  zum IFS drive und dem Microsoft Web Storage System finden sich hier: <a title="Microsoft docs: IFS, Web storage system..." href="http://support.microsoft.com/kb/294312/en-us/" target="_blank">http://support.microsoft.com/kb/294312/en-us/</a></p>
<p>Der Artikel betont auch noch einmal, daß diese Methode zwar zum Extrahieren von Dokumenten geeignet ist, nicht aber zum Zurückschreiben, denn man wird aller Wahrscheinlichkeit nach die darunterliegende Autoren-/Rechtestruktur kompromittieren.</p>
<h3>Sharepoint Server 2003 alias Sharepoint 2: Dokumentenexport mit IronPython</h3>
<p>IronPython, Microsofts Python-Implementierung in der Version 2.6 bei codeplex ( <a title="IronPython" href="http://ironpython.codeplex.com/ ">http://ironpython.codeplex.com/ </a>) ermöglicht, Dotnet-Assemblies auf einfachste Weise einzuhängen, z.B. mit clr.AddReference(&#8216;Microsoft.SharePoint&#8217;)</p>
<p>Hier ist der Code, um eine einzelne Dokumentenbibliothek auszulesen und auf eine lokale Platte unter Beibehaltung der <em>timestamps</em> zu spiegeln:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># --------------------------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Dokumentenimport von MS SharePoint.</span>
<span style="color: #808080; font-style: italic;"># Die originale Ordnerstruktur wird abgebildet; Zeitstempel der Dokumente bleibt erhalten.</span>
<span style="color: #808080; font-style: italic;"># Autor: weitlandt. Klaus Stein 29.10.09</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Umgebung: Ironpython 2.6+ (www.ironpython.com bzw. codeplex.com)</span>
<span style="color: #808080; font-style: italic;">#</span>
&nbsp;
SAVE_TO = <span style="color: #483d8b;">&quot;C:/SHP2&quot;</span>
SITEURL = <span style="color: #483d8b;">&quot;http://localhost&quot;</span>
DOCROOT = <span style="color: #483d8b;">&quot;Shared Documents&quot;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># -----------------------------</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>,<span style="color: #dc143c;">sys</span>,<span style="color: #dc143c;">stat</span>,<span style="color: #dc143c;">array</span>,io,clr
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">datetime</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #66cc66;">*</span>
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">time</span> <span style="color: #ff7700;font-weight:bold;">import</span> mktime <span style="color: #ff7700;font-weight:bold;">as</span> mktime
&nbsp;
clr.<span style="color: black;">AddReference</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Microsoft.SharePoint'</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">from</span> Microsoft.<span style="color: black;">SharePoint</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #66cc66;">*</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> storefile<span style="color: black;">&#40;</span>f,basedir,relpath<span style="color: black;">&#41;</span>:
  ptmp,ntmp = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span>relpath<span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">isdir</span><span style="color: black;">&#40;</span>basedir + ptmp<span style="color: black;">&#41;</span>:
    <span style="color: #dc143c;">os</span>.<span style="color: black;">mkdir</span><span style="color: black;">&#40;</span>basedir + ptmp<span style="color: black;">&#41;</span>
  a = f.<span style="color: black;">ModifiedBy</span>.<span style="color: black;">ToString</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  d = f.<span style="color: black;">OpenBinary</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  m = <span style="color: #dc143c;">datetime</span><span style="color: black;">&#40;</span>f.<span style="color: black;">TimeLastModified</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">print</span> f.<span style="color: black;">Name</span>+<span style="color: #483d8b;">&quot; (&quot;</span> + d.<span style="color: black;">Length</span>.<span style="color: black;">ToString</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>+<span style="color: #483d8b;">&quot;), Letzte Speicherung von &quot;</span>+a+<span style="color: #483d8b;">&quot;: &quot;</span>+m.<span style="color: black;">ToString</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  fullpath = basedir + relpath
  b = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>fullpath,mode=<span style="color: #483d8b;">&quot;w+b&quot;</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> d: <span style="color: #808080; font-style: italic;">#</span>
    b.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #008000;">chr</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  b.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  ts = <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>mktime<span style="color: black;">&#40;</span>m.<span style="color: black;">timetuple</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  <span style="color: #dc143c;">os</span>.<span style="color: black;">utime</span><span style="color: black;">&#40;</span>fullpath,<span style="color: black;">&#40;</span>ts,ts<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># timestamp setzen</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># main()</span>
&nbsp;
tstart = <span style="color: #dc143c;">datetime</span>.<span style="color: black;">now</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">isdir</span><span style="color: black;">&#40;</span>SAVE_TO<span style="color: black;">&#41;</span>:
  <span style="color: #dc143c;">os</span>.<span style="color: black;">mkdir</span><span style="color: black;">&#40;</span>SAVE_TO<span style="color: black;">&#41;</span>
&nbsp;
S = SPSite<span style="color: black;">&#40;</span>SITEURL<span style="color: black;">&#41;</span>
W = S.<span style="color: black;">OpenWeb</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Importieren von: &quot;</span> + W.<span style="color: black;">Title</span> + <span style="color: #483d8b;">&quot; (&quot;</span> + W.<span style="color: black;">Url</span> + <span style="color: #483d8b;">&quot;)&quot;</span>
&nbsp;
R = W.<span style="color: black;">GetListsOfType</span><span style="color: black;">&#40;</span>SPBaseType.<span style="color: black;">DocumentLibrary</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span>DOCROOT<span style="color: black;">&#93;</span> <span style="color: #808080; font-style: italic;"># nur diesen Ordner</span>
skip = <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>DOCROOT<span style="color: black;">&#41;</span>
cnt = <span style="color: #ff4500;">0</span>
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> R.<span style="color: black;">Items</span>:
  relpath = i.<span style="color: black;">File</span>.<span style="color: black;">ToString</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span>skip:<span style="color: black;">&#93;</span> <span style="color: #808080; font-style: italic;"># Das Startverzeichnis abgeschneiden</span>
  storefile<span style="color: black;">&#40;</span>i.<span style="color: black;">File</span>,SAVE_TO,relpath<span style="color: black;">&#41;</span>
  cnt = cnt + <span style="color: #ff4500;">1</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Fertig. Angelegt: &quot;</span> + cnt.<span style="color: black;">ToString</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;, Zeit: &quot;</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">datetime</span>.<span style="color: black;">now</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> - tstart<span style="color: black;">&#41;</span>
W.<span style="color: black;">Dispose</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
S.<span style="color: black;">Dispose</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;"># ----</span></pre></div></div>

<p>&#8230;das ist alles! Für Erweiterungen bietet sich an, die Objekteigenschaften von &#8216;Items&#8217; einmal genauer anzusehen &#8211; da ist noch etliches nützliches dabei.</p>
]]></content:encoded>
			<wfw:commentRss>http://weitlandt.com/theme/2009/11/dokumente-aus-sharepoint-2001-und-2003-extrahieren/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
