예제 #1
0
파일: Utils.cs 프로젝트: modulexcite/pash-1
        internal static string GetWellKnownGuidDN(ADSessionInfo adSession, string partitionDN, string wellKnownGuid)
        {
            string distinguishedName;

            if (partitionDN != null)
            {
                ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(adSession);
                try
                {
                    try
                    {
                        aDObjectSearcher.SearchRoot = string.Format("<WKGUID={0},{1}>", wellKnownGuid, partitionDN);
                        aDObjectSearcher.Scope      = ADSearchScope.Base;
                        aDObjectSearcher.Filter     = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
                        ADObject aDObject = aDObjectSearcher.FindOne();
                        if (aDObject == null)
                        {
                            distinguishedName = null;
                        }
                        else
                        {
                            distinguishedName = aDObject.DistinguishedName;
                        }
                    }
                    catch (ADIdentityNotFoundException aDIdentityNotFoundException1)
                    {
                        ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1;
                        DebugLogger.LogError("Utils", string.Format("Error in searching for WKGUID {0}", aDIdentityNotFoundException.Message));
                        distinguishedName = null;
                    }
                }
                finally
                {
                    aDObjectSearcher.Dispose();
                }
                return(distinguishedName);
            }
            else
            {
                return(null);
            }
        }