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); }
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); } }
public string RetrieveOU(AppsService UserService, string OuPath) { var Token = UserService.Groups.QueryClientLoginToken(); var OUService = new Dgc.GoogleAppService(); var CustId = OUService.GetCustomerId(UserService); var uri = new Uri("https://apps-apis.google.com/a/feeds/orgunit/2.0/" + CustId + "/"+OuPath); WebRequest WebRequest = WebRequest.Create(uri); WebRequest.Method = "GET"; WebRequest.ContentType = "application/atom+xml; charset=UTF-8"; WebRequest.Headers.Add("Authorization: GoogleLogin auth=" + Token); WebResponse WebResponse = WebRequest.GetResponse(); if (WebResponse == null) { throw new Exception("WebResponse is null"); } StreamReader SR = new StreamReader(WebResponse.GetResponseStream()); var _Result = SR.ReadToEnd().Trim(); return _Result; }