/// <summary> /// Obtain the SID for the local group or domain local group (if Domain Controler) /// </summary> /// <param name="groupName">group name</param> /// <returns>security identifier of the group</returns> internal static SecurityIdentifier GetGroupSid(string groupName) { NTAccount identity; if (!IsDomainController()) { identity = new NTAccount(Environment.MachineName, groupName); } else { identity = new NTAccount(Domain.GetComputerDomain().Name, groupName); } try { return(identity.Translate(typeof(SecurityIdentifier)) as SecurityIdentifier); } catch (System.Security.Principal.IdentityNotMappedException) { if (!DomainUtil.IsInDomain()) { return(DomainUtil.LookupAccountName(Environment.MachineName, groupName)); } // Unable to find a local group. // this might happen in contexts like WAHS where not all groups are used/created by setup (delegated admin, etc). return(null); } }
/// <summary> /// Generate a node info instance /// </summary> /// <param name="nodeName">indicating the node name</param> /// <param name="domainName">indicating the FQDN</param> /// <returns>returns the node info instance</returns> internal static NodeInfo GenerateNodeInfo(string nodeName, string domainName) { Exception ex = null; string ssdl = string.Empty; // Can't get the SID of the Azure node or Non-Domain joined if (!SoaHelper.IsOnAzure() && DomainUtil.IsInDomain()) { ssdl = BrokerNodesManager.GetSDDI(nodeName, out ex); } return(new NodeInfo(nodeName, domainName, ssdl, ex)); }