Ejemplo n.º 1
0
        public static ADObjectId GetUpdatedADObjectIdWithDN(ADObjectId adObject, string tenantDistinguishedName, Guid tenantGuid, ADObjectId relativeConfigDN = null)
        {
            if (adObject == null || string.IsNullOrEmpty(tenantDistinguishedName))
            {
                return(null);
            }
            if (tenantGuid == Guid.Empty || adObject.ObjectGuid == Guid.Empty)
            {
                throw new InvalidOperationException(string.Format("Unable to fix distinguished name for ADObject = {0}, TenantGuid = {1}, ObjectGuid = {2}, objectName = {3}.", new object[]
                {
                    adObject.GetType().Name,
                    tenantGuid,
                    adObject.ObjectGuid,
                    adObject.Name
                }));
            }
            string     unescapedCommonName = string.IsNullOrEmpty(adObject.Name) ? adObject.ObjectGuid.ToString() : adObject.Name;
            ADObjectId adobjectId          = new ADObjectId(tenantDistinguishedName, tenantGuid);
            ADObjectId adobjectId2         = new ADObjectId(adobjectId.GetChildId("Configuration").DistinguishedName, tenantGuid);

            if (relativeConfigDN != null)
            {
                adobjectId2 = new ADObjectId(adobjectId2.GetDescendantId(relativeConfigDN).DistinguishedName, tenantGuid);
            }
            return(new ADObjectId(adobjectId2.GetChildId(unescapedCommonName).DistinguishedName, adObject.ObjectGuid));
        }