Skip to content

Instantly share code, notes, and snippets.

View tomorgan's full-sized avatar

Tom Morgan tomorgan

View GitHub Profile
@tomorgan
tomorgan / PS_LDAP_Request
Created March 1, 2013 14:18
Powershell LDAP Request to get AD objects including Lync SIP Address and Home Server. Good if you can't use Import-Module ActiveDirectory
$Request = New-Object System.DirectoryServices.Protocols.SearchRequest
$Request.DistinguishedName = $RootContainer
$Request.Filter = $SearchFilter
$Request.Scope = "Subtree"
$Request.Attributes.Add("distinguishedName") | Out-Null
$Request.Attributes.Add("objectclass") | Out-Null
$Request.Attributes.Add("mail") | Out-Null
$Request.Attributes.Add("objectguid") | Out-Null
$Request.Attributes.Add("msrtcsip-primaryhomeserver") | Out-Null
Function Get-UserPrincipal($userName)
{
$dsam = "System.DirectoryServices.AccountManagement"
$rtn = [reflection.assembly]::LoadWithPartialName($dsam)
$cType = "domain" #context type
$iType = "DistinguishedName"
$dsamUserPrincipal = "$dsam.userPrincipal" -as [type]
$principalContext = new-object "$dsam.PrincipalContext"($cType,$RootDomain)
Write-Host Looking for DN $UserName in Container $principalContext.Name
Function Populate-UserObject($UserArg)
{
$thisUser = new-Object($t + ".User")
$thisUser.Name = $UserArg.Name
$thisUser.Email = $UserArg.EmailAddress
$thisUser.ID = $UserArg.Guid
$innerObject = $UserArg.GetUnderlyingObject()
$thisUser.SIP = $innerObject."msRTCSIP-PrimaryUserAddress"
return $thisUser
}
@tomorgan
tomorgan / UCMA UserEndpoint Sending IM Example.cs
Created March 4, 2013 17:14
Simplest example using UCMA UserEndpoint to send an IM. Note: no error handling, assumes IM always accepted etc. For learning only :)
using Microsoft.Rtc.Collaboration;
using System;
namespace SimpleUserUCMA
{
class Program
{
private const string sipaddress = "sip:from@domain.com";
private const string username = "USERNAME";
private const string password = "PASSWORD";
@tomorgan
tomorgan / gist:5538620
Created May 8, 2013 06:25
Using the Microsoft Lync SDK
//add the using decalarion
using Microsoft.Lync.Model;
//then, at some point in your application, create a LyncClient object and get a reference to the running Lync Client.
//(one of the nice things about making CWEs is that you can rely on the Lync Client being installed & running!
var lyncClient = LyncClient.GetClient();
//There's loads of functionality here. For instance, managing the user contact lists can be done by getting a reference to
//the Contact Manager
ContactManager = lyncClient.ContactManager;
@tomorgan
tomorgan / gist:5538654
Created May 8, 2013 06:37
Lync CWE Registry Keys
Windows Registry Editor Version 5.00
#Lync 2010
[HKEY_CURRENT_USER\Software\Microsoft\Communicator\ContextPackages\{12345-YOUR-GUID-HERE-54321}]
"Name"="The name of your CWE"
"InternalURL"="http://thoughtstuff.co.uk/internal.html"
"ExternalURL"="http://thoughtstuff.co.uk/external.html"
"ExtensibilityWindowSize"=dword:00000001
@tomorgan
tomorgan / gist:5538669
Last active December 17, 2015 02:49
Lync 2013 Trusted Sites
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Office\Lync\Security\Trusted Sites\thoughtstuff.co.uk]
"http"=dword:00000001
"https"=dword:00000001
#This example allows both http and https traffic to the thoughtstuff.co.uk domain.
@tomorgan
tomorgan / BusylightSDK-Light
Last active December 17, 2015 11:39
Busylight SDK for Microsoft Lync: Basic Light example. Cycle through the available colours
using Plenom.Components.Busylight.Sdk;
using System.Threading;
namespace ThoughtStuff.BusylightSDK
{
class Program
{
static void Main(string[] args)
{
//Instantiate BusyLightController for either Lync or UC:
@tomorgan
tomorgan / BusylightSDK-Pulse
Last active December 17, 2015 11:39
Busylight SDK for Microsoft Lync: Example using Pulse command, which can be used to alter opacity and fade the light in and out.
using Plenom.Components.Busylight.Sdk;
using System.Threading;
namespace ThoughtStuff.BusylightSDK
{
class Program
{
static void Main(string[] args)
{
//Instantiate BusyLightController for either Lync or UC:
@tomorgan
tomorgan / BusylightSDK-Alert
Last active December 17, 2015 11:39
Busylight SDK for Microsoft Lync: Example using the Alert method, to produce a sound and light alert.
using Plenom.Components.Busylight.Sdk;
using System.Threading;
namespace ThoughtStuff.BusylightSDK
{
class Program
{
static void Main(string[] args)
{
//Instantiate BusyLightController for either Lync or UC: