Giter VIP home page Giter VIP logo

active-directory-photo-toolkit's Introduction

Icon

Active Directory Photo Toolkit Build status

Installation

Installation is done via NuGet:

Install-Package ActiveDirectoryPhotoToolkit

Usage

Initial setup:

var activeDirectoryPhoto = new ActiveDirectoryPhoto();

Retrieve a users profile photo from Active Directory

var username = "ghuntley";
var format = ActiveDirectoryPhoto.Format.PNG;
var thumbnailPhoto = activeDirectoryPhoto.GetThumbnailPhoto(username, format);

Available formats are available in the ActiveDirectoryPhoto.Format enum.

 public enum Format
    {
        Bmp, 
        Gif, 
        Jpg, 
        Png
    };

Saving a retrieved user profile photo to disk in the same folder as the execution, after using the above sample

activeDirectoryPhoto.SaveThumbnailToDisk(thumbnailPhoto);

Saving a retrieved user to a specific folder, after using the retrieve a thumbnail example

activeDirectoryPhoto.SaveThumbnailToDisk(thumbnailPhoto, "C:\\");

Setting a users profile photo

var username = "ghuntley";
var photo = @"C:\photo.jpg";
activeDirectoryPhoto.SetThumbnailPhoto(username, photo);

Removing a users profile photo

var username = "ghuntley";
activeDirectoryPhoto.RemoveThumnnailPhoto(username);

Custom Exceptions

There are two custom exceptions currently which can be caught and handled however you like.

  • PhotoResolutionInvalidException - Thrown when the image selected to upload is larger than 200x200px which is the limit set in Active Directory.
  • PhotoTooLargeException - Thrown when the image selected is larger than 100kb, again this is a limit set in Acitve Directory.

With thanks to

active-directory-photo-toolkit's People

Contributors

captainqwerty avatar ghuntley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  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.