Click here to Skip to main content
15,896,730 members

Comments by diialer (Top 8 by date)

diialer 12-Aug-11 8:15am View    
P.D: http://msdn.microsoft.com/en-us/library/system.security.principal.aspx
P.D2: Right-Click the dll. For testing add the User Everyone with full privilegs (better with the whole folder)

if this does not help use the method i postet before
export this to a method

if ( ! string.IsNullOrEmpty( user ) )
{
// Call LogonUser to get a token for the user
bool loggedOn = LogonUser( user, domain, password,
9 /*(int)LogonType.LOGON32_LOGON_NEW_CREDENTIALS*/,
3 /*(int)LogonProvider.LOGON32_PROVIDER_WINNT50*/,
out userHandle );
if ( !loggedOn )
throw new Win32Exception( Marshal.GetLastWin32Error() );

// Begin impersonating the user
impersonationContext = WindowsIdentity.Impersonate( userHandle );
}

use method in doSomeThingWithAdministrativePrivilegs()
...
// DO the stuff privilegs needed in here...

put the method doSomeThingWithAdministrativePrivilegs() where your if ( ! string.IsNullOrEmpty( user ) ) ... was
you also can pass the user, password....
doSomeThingWithAdministrativePrivilegs(string user, string domain, string password)

you have to change the following lines in the method:
<$user>, //Administrator or User with administrativ privilegs
<$domain>, //if no domain avalible set computername System.Environment.MachineName it was i think .ToString()...
<$password>,
this is for example the domain administrator or a user who has administrativ privilegs in domain...

AND to use local administrator if possible:
Create manifest file for main application and add

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestversion="1.0">
<assemblyidentity version="1.0.0.0"
="" processorarchitecture="X86" name="someExecName" type="win32">
<description>Your Program Description
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"><security>
<requestedprivileges>
<requestedexecutionlevel level="requireAdministrator">


</trustInfo>
diialer 5-Aug-11 10:40am View    
no the problem was that i'd no permissions to create views -.-
work with the solution to create a view and select from the view now...
diialer 5-Aug-11 10:32am View    
just got the rights to create and delete views...
thanks
diialer 5-Aug-11 10:24am View    
already tried this
string selectCommandTemperature = "CREATE VIEW temp AS (SELECT [T/°C] FROM Q3B UNION SELECT [T/°C] FROM Q3D); SELECT TOP " + countTempe + " [T/°C] FROM temp";
also doesn't work...
diialer 5-Aug-11 10:12am View    
How can i create the view in the database?
(the database is far away (geographical) and i only've got permissions to select in 2 databases with about 1000 tables each)