Пример #1
0
        public static Domain GetRootDomain()
        {
            try
            {
                Configuration adsiConfig = Configuration.GetConfig();

                string rootDomainFullPath = AddADSIPath(adsiConfig.RootDomainPath, Path.GC);
                Domain rootDomainEntry    = Domain.GetDomain(rootDomainFullPath, adsiConfig.UserName, adsiConfig.Password, adsiConfig.AuthenticationType);
                return(rootDomainEntry);
            }
            catch (COMException exc)
            {
                Exceptions.LogException(exc);
                return(null);
            }
        }
Пример #2
0
        public static Domain GetDomainByBIOSName(string Name)
        {
            Configuration adsiConfig = Configuration.GetConfig();

            // Only access CrossRefCollection if LDAP is accessible
            if (adsiConfig.RefCollection != null && adsiConfig.RefCollection.Count > 0)
            {
                CrossReferenceCollection.CrossReference refObject = adsiConfig.RefCollection.ItemByNetBIOS(Name);
                string path   = AddADSIPath(refObject.DomainPath, Path.GC);
                Domain domain = Domain.GetDomain(path, adsiConfig.UserName, adsiConfig.Password, adsiConfig.AuthenticationType);

                return(domain);
            }
            else
            {
                return(null);
            }
        }