<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[SecurityDescriptor]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich spiele gerade etwas mit den ACE ACL usw. Jetzt hab ich mir mal folgendes kleines Programm geschrieben:</p>
<pre><code class="language-cpp">int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
    DWORD dwRet=0;
    getSecurityPriv();
    iOvertakeSecurity(&quot;C:\\temp&quot;, &quot;C:\\test&quot;);
    dwRet=GetLastError();
    return 0;
}
int iOvertakeSecurity(char *pcSource, char *pcDestination)
{
	Dword dwResult = 0;
	static byte buf[65536];
	char cMessage[1220]= {0};

	if (!GetFileSecurity(pcSource,
		DACL_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION, 
		(SECURITY_DESCRIPTOR *) &amp;buf[0],
		sizeof buf,
		&amp;dwResult))
	{
		return 1;
	}
	if (!SetFileSecurity(pcDestination,
	   DACL_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION, 
		(SECURITY_DESCRIPTOR *) &amp;buf[0]))
	{
		return 2;
	}
	LocalFree(&amp;buf[0]);

	return 0;
}

int getSecurityPriv( void )
{
	HANDLE hToken;
	LUID privValue;
	TOKEN_PRIVILEGES tkp;
	DWORD rc = 0;

	if ( OpenProcessToken( GetCurrentProcess(),
		TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &amp;hToken ) )
	{
		if ( LookupPrivilegeValue( NULL, SE_SECURITY_NAME, &amp;privValue ) )
		{
			tkp.PrivilegeCount = 1;
			tkp.Privileges[0].Luid = privValue;
			tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

			if ( ! AdjustTokenPrivileges( hToken, FALSE, &amp;tkp, sizeof tkp, NULL, NULL ) )
				rc = GetLastError();
		}
		else
			rc = GetLastError();
	}
	else
	{
		rc = GetLastError();
		hToken = INVALID_HANDLE_VALUE;
	}

	if ( hToken != INVALID_HANDLE_VALUE )
		CloseHandle( hToken );

	if ( rc )
		SetLastError( rc );

	return rc == 0;
}
</code></pre>
<p>Ich bekomm immer ERROR_INVALID_OWNER (1307L) als letzten Error zurück, was soviel heißt wie &quot;Diese Sicherheitskennung kann nicht als Besitzer des Objekts zugeordnet werden. (0x51b)&quot;. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> Mein Quellverzeichnis, wo ich mir den Owner herhole, und mein Zielverzeichnis, was ich ändern will, sind doch auf meinem lokalen System, wieso kann dann dieser Owner nicht &quot;kopiert&quot; werden?<br />
Einer ne Idee?<br />
Bin für alles Dankbar.</p>
<p>Gruß Damion</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/74930/securitydescriptor</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 20:23:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/74930.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 25 May 2004 19:29:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to SecurityDescriptor on Tue, 25 May 2004 19:29:49 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich spiele gerade etwas mit den ACE ACL usw. Jetzt hab ich mir mal folgendes kleines Programm geschrieben:</p>
<pre><code class="language-cpp">int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
    DWORD dwRet=0;
    getSecurityPriv();
    iOvertakeSecurity(&quot;C:\\temp&quot;, &quot;C:\\test&quot;);
    dwRet=GetLastError();
    return 0;
}
int iOvertakeSecurity(char *pcSource, char *pcDestination)
{
	Dword dwResult = 0;
	static byte buf[65536];
	char cMessage[1220]= {0};

	if (!GetFileSecurity(pcSource,
		DACL_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION, 
		(SECURITY_DESCRIPTOR *) &amp;buf[0],
		sizeof buf,
		&amp;dwResult))
	{
		return 1;
	}
	if (!SetFileSecurity(pcDestination,
	   DACL_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION, 
		(SECURITY_DESCRIPTOR *) &amp;buf[0]))
	{
		return 2;
	}
	LocalFree(&amp;buf[0]);

	return 0;
}

int getSecurityPriv( void )
{
	HANDLE hToken;
	LUID privValue;
	TOKEN_PRIVILEGES tkp;
	DWORD rc = 0;

	if ( OpenProcessToken( GetCurrentProcess(),
		TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &amp;hToken ) )
	{
		if ( LookupPrivilegeValue( NULL, SE_SECURITY_NAME, &amp;privValue ) )
		{
			tkp.PrivilegeCount = 1;
			tkp.Privileges[0].Luid = privValue;
			tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

			if ( ! AdjustTokenPrivileges( hToken, FALSE, &amp;tkp, sizeof tkp, NULL, NULL ) )
				rc = GetLastError();
		}
		else
			rc = GetLastError();
	}
	else
	{
		rc = GetLastError();
		hToken = INVALID_HANDLE_VALUE;
	}

	if ( hToken != INVALID_HANDLE_VALUE )
		CloseHandle( hToken );

	if ( rc )
		SetLastError( rc );

	return rc == 0;
}
</code></pre>
<p>Ich bekomm immer ERROR_INVALID_OWNER (1307L) als letzten Error zurück, was soviel heißt wie &quot;Diese Sicherheitskennung kann nicht als Besitzer des Objekts zugeordnet werden. (0x51b)&quot;. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> Mein Quellverzeichnis, wo ich mir den Owner herhole, und mein Zielverzeichnis, was ich ändern will, sind doch auf meinem lokalen System, wieso kann dann dieser Owner nicht &quot;kopiert&quot; werden?<br />
Einer ne Idee?<br />
Bin für alles Dankbar.</p>
<p>Gruß Damion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/527213</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/527213</guid><dc:creator><![CDATA[Damion]]></dc:creator><pubDate>Tue, 25 May 2004 19:29:49 GMT</pubDate></item><item><title><![CDATA[Reply to SecurityDescriptor on Tue, 25 May 2004 20:13:48 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>hat sich erledigt. Ich hatte nicht genügend Privilegien. Man braucht noch die Privilegien SE_RESTORE_NAME und SE_SECURITY_NAME.</p>
<p>Gruß Damion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/527247</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/527247</guid><dc:creator><![CDATA[Damion]]></dc:creator><pubDate>Tue, 25 May 2004 20:13:48 GMT</pubDate></item></channel></rss>