Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2006

Tip: Looking for answers? Try searching our database.

Pinvoke and Win32 level API permissions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
r - 20 Jan 2006 22:27 GMT
I have a console based .net 2.0 C# application that fails on a PInvoke
call to the HrESEBackupPrepare() function in the Exchange backup API.

How can I determine if the failure is due to .NET 2.0 or Windows 2003
server restricting the permissions of the application?

HrESEBackupPrepare() returns 5
GetLastError() returns 1008 (0x000003F0)
FormatMessage returns
"An attempt was made to reference a token that does not exist"
1008 is windows error "ERROR_NO_TOKEN"

Windows Server 2003
Exchange 2003

I am logged into the machine as a domain administrator and that domain
administrator is a member of the local backup operators group.

The online doucmentation for HrESEBackupPrepare() doesn't help much
because it does not explain how to correct this error.

It only lists three lines for errors:

  S_OK - no error
  ESE specific error code - see esebkmsg.h from the Exchange SDK
  Other - a Win32 API or RPC error

Google groups contains many questions asking why this api fails but
almost no responses.
Willy Denoyette [MVP] - 20 Jan 2006 22:55 GMT
You should not call GetLastError when using PInvoke, the error returned
(1008) is probably not the 'real' value but an intermediate. Use
Marshal.GetLastWin32Error instead.

Willy.

| I have a console based .net 2.0 C# application that fails on a PInvoke
| call to the HrESEBackupPrepare() function in the Exchange backup API.
[quoted text clipped - 25 lines]
| Google groups contains many questions asking why this api fails but
| almost no responses.
r - 23 Jan 2006 16:36 GMT
I use Marshal.GetLastWin32Error() to get the last win32
error.

I have "SetLastError=true" for the DLLImportAttribute() and use
the following code to get the error string (this is easier than
directly calling FormatMessage() win32 api)

   e = Marshal.GetLastWin32Error();

   System.ComponentModel.Win32Exception t = new System.ComponentModel.Win32Exception(e);

   Console.WriteLine(t.Message);  //easier than
               //importing and calling FormatMessage() win32 API call

Is there some .NET application setting or windows setting that I
need to do so that the .NET application runs using the the user
I am logged in as (a domain administrator)?

Thank you for your earlier reply.

> You should not call GetLastError when using PInvoke, the error returned
> (1008) is probably not the 'real' value but an intermediate. Use
[quoted text clipped - 31 lines]
> | Google groups contains many questions asking why this api fails but
> | almost no responses.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.