[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-1662?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14599286#comment-14599286
 ] 

Michael Osipov edited comment on HTTPCLIENT-1662 at 6/24/15 12:05 PM:
----------------------------------------------------------------------

I would rather disallow fully-qualified domain names and accept netbios ones. 
To make it reliable, one would need to have the source code of {{DsGetDcName}} 
or try to find appropriate ones in Samba.

One approapriate and portable way to convert that is to perform this LDAP query:

{code}
public string GetNetbiosDomainName(string dnsDomainName)
{
        string netbiosDomainName = string.Empty;

        DirectoryEntry rootDSE = new 
DirectoryEntry(string.Format("LDAP://{0}/RootDSE", dnsDomainName));

        string configurationNamingContext = 
rootDSE.Properties["configurationNamingContext"][0].ToString();

        DirectoryEntry searchRoot = new DirectoryEntry("LDAP://cn=Partitions," 
+ configurationNamingContext);

        DirectorySearcher searcher = new DirectorySearcher(searchRoot);
        searcher.SearchScope = SearchScope.OneLevel;
        // searcher.PropertiesToLoad.Add("netbiosname");
        searcher.Filter = 
string.Format("(&(objectcategory=Crossref)(dnsRoot={0})(netBIOSName=*))", 
dnsDomainName);

        SearchResult result = searcher.FindOne();

        if (result != null)
        {
                netbiosDomainName = 
result.Properties["netbiosname"][0].ToString();
        }

        return netbiosDomainName;
}
{code}

Don't worry that this is C#, it works with Java too. Just tried that with our 
forest and it works. Source: 
http://www.sghaida.com/c-how-to-get-domain-controller-netbios-name-from-dns-name/


was (Author: michael-o):
I would rather disallow fully-qualified domain names and accept netbios ones. 
To make it reliable, one would need to have the source code of {{DsGetDcName}} 
or try to find appropriate ones in Samba.

> NTLM auth failed because NTLMEngineImpl strip domain to base domain name
> ------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1662
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1662
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpAuth
>    Affects Versions: 4.5
>         Environment: HttpClient 4.3, 4.5
> A http site with NTLM auth
> A domain which Netbios name is not match domain name(e.g. 
> domain=mydomain.com; netbios name= testdomain)
>            Reporter: Colin
>            Assignee: Karl Wright
>         Attachments: HTTPCLIENT-1662.patch
>
>
> When generate type 3 message, we change the domain name to base domain name:
> {code}
>             // Use only the base domain name!
>             final String unqualifiedDomain = convertDomain(domain);
> {code}
> {code}
>     /** Strip dot suffix from a name */
>     private static String stripDotSuffix(final String value) {
>         if (value == null) {
>             return null;
>         }
>         final int index = value.indexOf(".");
>         if (index != -1) {
>             return value.substring(0, index);
>         }
>         return value;
>     }
>     /** Convert domain to standard form */
>     private static String convertDomain(final String domain) {
>         return stripDotSuffix(domain);
>     }
> {code}
> I got http 401 in my environment with correct credential and found the root 
> cause is those code got wrong domain name so the domain controller return a 
> NTLM sub status code 0xC0000064, which means " The username you typed does 
> not exist!"
> The Netbios name of a domain is the "Pre Windows 2000 name" of the domain.
> Is there any issue to use full domain name?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to