public static ProvisionResponse GrantMSLAccess(string env, string user, string pcn, bool needPQRole) { ProvisionResponse result = new ProvisionResponse(); try { //if (string.IsNullOrWhiteSpace(user)) user = Thread.CurrentPrincipal.Identity.Name; ActiveDirectoryHelper.ValidateUser(user); string response = SqlDataHelper.Provision(AppName.MSL, env, user, pcn, (needPQRole ? Properties.Resources.Query_MSL_PQ : Properties.Resources.Query_MSLAccess)); using (XmlReader reader = XmlReader.Create(new StringReader(response))) { XElement root = XElement.Load(reader); XmlNameTable nameTable = reader.NameTable; XmlNamespaceManager namespaceManager = new XmlNamespaceManager(nameTable); namespaceManager.AddNamespace("ns1", "http://MS.IT.Ops.MSLicense.TransactionService.DataContracts/"); XElement element = root.XPathSelectElement("/ns1:Accessor/ns1:AccessorStatus/ns1:StatusID", namespaceManager); if (element == null || element.Value != "1") { result.Status = "Error"; } else { result.Status = "Success"; result.Reason = "Access Granted"; } } } catch (Exception ex) { result.Status = "Error"; result.Reason = ex.Message; } return(result); }