GithubHelp home page GithubHelp logo

ramhemasri / simpleimpersonation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mattjohnsonpint/simpleimpersonation

0.0 1.0 0.0 153 KB

Simple Impersonation Library for .Net

License: MIT License

C# 100.00%

simpleimpersonation's Introduction

SimpleImpersonation

Simple Impersonation Library for .Net

This library provides a managed wrapper for the LogonUser function of the Win32 API. Basically, it allows you to impersonate any user, as long as you have their credentials.

It is dual compiled for both .Net 2.0 and .Net 4.0 runtimes. It should work well under .Net 2.0, 3.0, 3.5, 4.0, 4.5, and the client profiles. It has no dependencies.

Installation

Use NuGet package SimpleImpersonation.

PM> Install-Package SimpleImpersonation

Usage

using (Impersonation.LogonUser(domain, username, password, logonType))
{
    // do whatever you want as this user.
}

Be sure to specify a logon type that makes sense for what you are doing. For example:

  • If you are interactively working as a particular user from a desktop application, use LogonType.Interactive.

  • If you are trying to connect to a SQL server with trusted authentication using specific credentials, use LogonType.NewCredentials.

    • But be aware that impersonation is not taken into account in connection pooling.
    • You will also need to vary your connection string.
    • Read more here

See the MSDN documentation for additional logon types.

simpleimpersonation's People

Contributors

mattjohnsonpint avatar

Watchers

Ram Hemasri avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.