internal static string FindUniqueCN(IRecipientSession session, ADObjectId parentId, string cnOrig)
        {
            string suffix = "";

            for (int i = 1; i < 100; i++)
            {
                string text = InitializeExchangeUniversalGroups.Concat(cnOrig, suffix, 64);
                if (session.Read(parentId.GetChildId(text)) == null)
                {
                    return(text);
                }
                suffix = i.ToString();
            }
            return(InitializeExchangeUniversalGroups.Concat(cnOrig, Guid.NewGuid().ToString("N"), 64));
        }
        internal static string FindUniqueSamAccountName(IRecipientSession session, ADObjectId dom, string samOrig)
        {
            string suffix = "";

            for (int i = 1; i < 100; i++)
            {
                string       text   = InitializeExchangeUniversalGroups.Concat(samOrig, suffix, 256);
                QueryFilter  filter = new ComparisonFilter(ComparisonOperator.Equal, IADSecurityPrincipalSchema.SamAccountName, text);
                ADRawEntry[] array  = session.Find(dom, QueryScope.SubTree, filter, null, 1);
                if (array.Length == 0)
                {
                    return(text);
                }
                suffix = i.ToString();
            }
            return(InitializeExchangeUniversalGroups.Concat(samOrig, Guid.NewGuid().ToString("N"), 256));
        }