Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Windows Security

Posted on 1998-10-06
5
Medium Priority
?
241 Views
Last Modified: 2010-04-01
I'm going to leave this rather broad, let me know if I need to be more specific...

What I'm building is an application, which allows users to copy files to an NT machine on the network.  This program will have many users, some may have access permissions to the target machine, but most will not.  Is there a way through code, to impersonate a user with adequate permissions to make the copy?  I'm not sure if network protocol is significant but our LAN is TCP/IP.  Client machines may be Win95, Win98 or WinNT, while the target machine is always going to be WinNT.

Any documentation, mention of APIs would be great.  Code snippets would be cool, but not neccessary.

-Ray
0
Comment
Question by:rayb
  • 3
  • 2
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 1174537
The answer is quite simple:
Assuming you're writing a server application, you'll have to leave out some calls - e.g. if you're using named pipes, you'd usually call 'InpersonateNamedPipeClient()' to adjust the server process' privileges to the level of the client. (using RPC, you'd leave out the call to 'RpcImpersonateClient()'.
Additionally, the general function call would be 'ImpersonateLoggedOnUser()' with a prior call to obtain a impersonation access token.
If you're writing a client application that uses network shares, you don't have to take care of this at all - the OS will do it.

Feel free to ask followup questions, as this is quite a difficult issue...
0
 
LVL 2

Author Comment

by:rayb
ID: 1174538
I'm rejecting based on the fact, that I stumbled across these functions earlier, and the documentation states that they are only supported by NT.  If you are certain that the documentation is wrong in this regard, and the functions will work for both Win95 and Win98 as well as NT, post a follow up response and I'll code myself a prototype to verify it, but otherwise I'd rather not waste the effort.

0
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 1174539
Your target machine is NT - and as i stated, when you're writing a server app on NT, you'll need this functions. OF COURSE they're not supported on Win9x. If your application is a client, the latter applies - you don't have to take care, as the OS does.

At least you made clear that you're not writing a server application running on NT.

So see the following scenario:
Your application is running, you want to copy a file to \\server\disk1
1. The resource is already  connected, no authentication, hence.
2. No resource present, your app calls 'WNetAddConnection2()' providing an appropriate user name and password.

Of course you'll have to add an account on the server, e.g. called 'mycopyjob'
0
 
LVL 2

Author Comment

by:rayb
ID: 1174540
Ah!!!
I like this answer better.  The WNetAddConnection2 is new info to me...  I more than likely won't be able to verify until tomorrow.  But when I do, I'll be back to award points and such.

Thanks jkr.

-Ray
0
 
LVL 2

Author Comment

by:rayb
ID: 1174541
jkr,

Works like a charm!  Thanks very much.

-Ray
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question