-
Notifications
You must be signed in to change notification settings - Fork 4
/
GDataOU.cs
139 lines (105 loc) · 3.39 KB
/
GDataOU.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using System;
using System.Diagnostics;
using System.Management.Automation;
using System.ComponentModel;
using Google.Contacts;
using Google.GData.Client;
using Google.GData.Contacts;
using Google.GData.Extensions;
using System.Collections.Generic;
using Google.GData.Apps;
using Google.GData.Apps.GoogleMailSettings;
using Google.GData.Extensions.Apps;
using System.Xml;
using System.Xml.Linq;
namespace Microsoft.PowerShell.GData
{
public class OrganizationalUnit
{
#region New-GDataOUService
[Cmdlet(VerbsCommon.New, "GDataOUService")]
public class NewGDataOUService : Cmdlet
{
#region Parameters
[Parameter(
Mandatory = true
)]
[ValidateNotNullOrEmpty]
public string AdminUsername
{
get { return null; }
set { _AdminUser = value; }
}
private string _AdminUser;
[Parameter(
Mandatory = true
)]
[ValidateNotNullOrEmpty]
public string AdminPassword
{
get { return null; }
set { _AdminPassword = value; }
}
private string _AdminPassword;
#endregion Parameters
protected override void ProcessRecord()
{
var _DgcGoogleAppsService = new Dgc.GoogleAppService();
var _Domain = _DgcGoogleAppsService.GetDomain(_AdminUser);
try
{
var _UserService = new AppsService(_Domain, _AdminUser, _AdminPassword);
WriteObject(_UserService);
}
catch (AppsException _Exception)
{
WriteObject(_Exception,true);
}
}
}
#endregion New-GDataUserService
#region Get-GDataOU
[Cmdlet(VerbsCommon.Get, "GDataOU")]
public class GetGDataUser : Cmdlet
{
#region Parameters
[Parameter(
Mandatory = true
)]
[ValidateNotNullOrEmpty]
public AppsService OUService
{
get { return null; }
set { _OUService = value; }
}
private AppsService _OUService;
[Parameter(Mandatory = false)]
[ValidateNotNullOrEmpty]
public string OuPath
{
get { return null; }
set { _OuPath = value; }
}
private string _OuPath;
#endregion Parameters
protected override void ProcessRecord()
{
var OUService = new Dgc.GoogleAppService();
string _Xml;
if (_OuPath != null)
{
_Xml = OUService.RetrieveOU(_OUService, _OuPath);
}
else
{
_Xml = OUService.RetrieveAllOUs(_OUService);
}
XmlDocument _XmlDoc = new XmlDocument();
_XmlDoc.InnerXml = _Xml;
XmlElement _Entry = _XmlDoc.DocumentElement;
WriteObject(_Entry);
}
}
#endregion Get-GDataUser
}
}