-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDirSearchClient_iOSViewController.cs
100 lines (87 loc) · 3.19 KB
/
DirSearchClient_iOSViewController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System;
using System.Drawing;
using Foundation;
using UIKit;
using DirectorySearcherLib;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System.Collections.Generic;
namespace DirSearchClient_iOS
{
public partial class DirSearchClientiOSViewController : UIViewController
{
public DirSearchClientiOSViewController(IntPtr handle)
: base(handle)
{
}
public override void DidReceiveMemoryWarning()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}
#region View lifecycle
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
SearchButton.TouchUpInside += async (object sender, EventArgs e) =>
{
if (string.IsNullOrEmpty(SearchTermText.Text))
{
StatusResult.Text = "Please Enter A Valid Search Term";
StatusResult.TextColor = UIColor.Black;
GivenResult.Text = "";
SurnameResult.Text = "";
UpnResult.Text = "";
PhoneResult.Text = "";
return;
}
List<User> results = await DirectorySearcher.SearchByAlias(SearchTermText.Text, new PlatformParameters(this));
if (results.Count == 0)
{
StatusResult.Text = "User Not Found";
StatusResult.TextColor = UIColor.Black;
GivenResult.Text = "";
SurnameResult.Text = "";
UpnResult.Text = "";
PhoneResult.Text = "";
}
else if (results[0].error != null)
{
StatusResult.Text = "Error! " + results[0].error;
StatusResult.TextColor = UIColor.Red;
GivenResult.Text = "";
SurnameResult.Text = "";
UpnResult.Text = "";
PhoneResult.Text = "";
}
else
{
StatusResult.TextColor = UIColor.Green;
StatusResult.Text = "Success";
GivenResult.Text = results[0].givenName;
SurnameResult.Text = results[0].surname;
UpnResult.Text = results[0].userPrincipalName;
PhoneResult.Text = results[0].telephoneNumber;
}
};
}
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
}
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
}
public override void ViewWillDisappear(bool animated)
{
base.ViewWillDisappear(animated);
}
public override void ViewDidDisappear(bool animated)
{
base.ViewDidDisappear(animated);
}
#endregion
}
}