private ADDomainInfo GetLDAPDomainInfo()
        {
            DirectoryEntry rootDse = new DirectoryEntry("LDAP://" + Server + "/RootDSE");

            if (Credential == null)
            {
                rootDse = new DirectoryEntry(@"LDAP://" + Server + (Port == 0 ? null : ":" + Port) + "/RootDSE", null, null, AuthenticationTypes.ServerBind | AuthenticationTypes.Secure | (Port == 636 ? AuthenticationTypes.SecureSocketsLayer : 0));
            }
            else
            {
                rootDse = new DirectoryEntry(@"LDAP://" + Server + (Port == 0 ? null : ":" + Port) + "/RootDSE", Credential.UserName, Credential.Password, AuthenticationTypes.ServerBind | AuthenticationTypes.Secure | (Port == 636 ? AuthenticationTypes.SecureSocketsLayer : 0));
            }
            return(ADDomainInfo.Create(rootDse));
        }
Example #2
0
 protected override ADDomainInfo GetDomainInfoInternal()
 {
     try
     {
         var data = Resource.Get();
         return(ADDomainInfo.Create(data));
     }
     catch (FaultException ex)
     {
         Trace.WriteLine("Fault Exception: " + ex.Message);
         Trace.WriteLine("Reason: " + ex.Reason);
         var stringWriter  = new StringWriter();
         var xmlTextWriter = new XmlTextWriter(stringWriter);
         var messageFault  = ex.CreateMessageFault();
         messageFault.WriteTo(xmlTextWriter, EnvelopeVersion.Soap12);
         var stringValue = Convert.ToString(stringWriter);
         Trace.WriteLine("Exception:");
         Trace.WriteLine(stringValue);
         Trace.WriteLine("The connection didn't worked");
         throw;
     }
 }
Example #3
0
        private ADDomainInfo GetLDAPDomainInfo()
        {
            DirectoryEntry rootDse;

            try
            {
                if (Credential == null)
                {
                    rootDse = new DirectoryEntry(@"LDAP://" + Server + (Port == 0 ? null : ":" + Port) + "/RootDSE", null, null, AuthenticationTypes.ServerBind | AuthenticationTypes.Secure | (Port == 636 ? AuthenticationTypes.SecureSocketsLayer : 0));
                }
                else
                {
                    rootDse = new DirectoryEntry(@"LDAP://" + Server + (Port == 0 ? null : ":" + Port) + "/RootDSE", Credential.UserName, Credential.Password, AuthenticationTypes.ServerBind | AuthenticationTypes.Secure | (Port == 636 ? AuthenticationTypes.SecureSocketsLayer : 0));
                }
                // force the connection to the LDAP server via an access to the "properties" property
                Trace.WriteLine("rootDse property count: " + rootDse.Properties.Count);
            }
            catch (COMException ex)
            {
                // Windows 2000 does not support a bind to the rootDse and returns "The server is not operational" (0x8007203A)
                if (ex.ErrorCode == -2147016646)
                {
                    if (Credential == null)
                    {
                        rootDse = new DirectoryEntry(@"LDAP://" + Server + (Port == 0 ? null : ":" + Port) + "/RootDSE", null, null, AuthenticationTypes.Secure | (Port == 636 ? AuthenticationTypes.SecureSocketsLayer : 0));
                    }
                    else
                    {
                        rootDse = new DirectoryEntry(@"LDAP://" + Server + (Port == 0 ? null : ":" + Port) + "/RootDSE", Credential.UserName, Credential.Password, AuthenticationTypes.Secure | (Port == 636 ? AuthenticationTypes.SecureSocketsLayer : 0));
                    }
                }
                else
                {
                    throw;
                }
            }
            return(ADDomainInfo.Create(rootDse));
        }
Example #4
0
        private ADDomainInfo GetLDAPDomainInfo()
        {
            DirectoryEntry rootDse = new DirectoryEntry("LDAP://" + Server + "/RootDSE");

            return(ADDomainInfo.Create(rootDse));
        }