0 people like it.

hf

jahn

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
open System.DirectoryServices

let modifyProxy (user:DirectoryEntry) found notFound =
    user.Properties.["proxyAddresses"]
    |> Seq.cast<string>
    |> Seq.tryFindIndex(fun x -> x.StartsWith("sip:", StringComparison.InvariantCultureIgnoreCase))
    |> function
        | Some(index) ->found user.Properties.["proxyAddresses"] index
        | None -> notFound user.Properties.["proxyAddresses"]

let setUserEnabled (user : DirectoryEntry) =
 // Add or Update the proxy address.
    let sip = String.Format("sip:{0}", user.Properties.["mail"].[0].ToString())
    modifyProxy user (fun pc i -> pc.[i] <- sip) (fun pc -> pc.Add sip |> ignore)

let setUserDisabled (user : DirectoryEntry) = 
    // Remove the SIP address.
    user.Properties.["msRTCSIP-PrimaryUserAddress"].Clear()
    modifyProxy user (fun pc i -> pc.RemoveAt i) ignore
namespace System
val modifyProxy : user:'a -> found:('b -> int -> 'c) -> notFound:('d -> 'c) -> 'c

Full name: Script.modifyProxy
val user : 'a
val found : ('b -> int -> 'c)
val notFound : ('d -> 'c)
module Seq

from Microsoft.FSharp.Collections
val cast : source:System.Collections.IEnumerable -> seq<'T>

Full name: Microsoft.FSharp.Collections.Seq.cast
Multiple items
val string : value:'T -> string

Full name: Microsoft.FSharp.Core.Operators.string

--------------------
type string = System.String

Full name: Microsoft.FSharp.Core.string
val tryFindIndex : predicate:('T -> bool) -> source:seq<'T> -> int option

Full name: Microsoft.FSharp.Collections.Seq.tryFindIndex
val x : string
System.String.StartsWith(value: string) : bool
System.String.StartsWith(value: string, comparisonType: System.StringComparison) : bool
System.String.StartsWith(value: string, ignoreCase: bool, culture: System.Globalization.CultureInfo) : bool
union case Option.Some: Value: 'T -> Option<'T>
val index : int
union case Option.None: Option<'T>
val setUserEnabled : user:'a -> unit

Full name: Script.setUserEnabled
val sip : obj
module String

from Microsoft.FSharp.Core
Multiple items
type Format<'Printer,'State,'Residue,'Result> = PrintfFormat<'Printer,'State,'Residue,'Result>

Full name: Microsoft.FSharp.Core.Format<_,_,_,_>

--------------------
type Format<'Printer,'State,'Residue,'Result,'Tuple> = PrintfFormat<'Printer,'State,'Residue,'Result,'Tuple>

Full name: Microsoft.FSharp.Core.Format<_,_,_,_,_>
val pc : obj
val i : int
val ignore : value:'T -> unit

Full name: Microsoft.FSharp.Core.Operators.ignore
val setUserDisabled : user:'a -> unit

Full name: Script.setUserDisabled

More information

Link:http://fssnip.net/gq
Posted:12 years ago
Author:
Tags: hf