Note that there are some explanatory texts on larger screens.

plurals
  1. POretrieving 'pre windows 2000 logon' name from LDAPMessage object in win32api C++
    primarykey
    data
    text
    <p>I've been asked to look at windows service which retrieves data from an Active Directory tree using the win32 LDAP API and outputs JSON data to a text file. It works fine but I need to modify it so that the i get the 'pre windows 2000' login name. The service is written in c++.</p> <p>The service already successfully retrieves various other attribute strings using:</p> <pre><code>PTSTR *pszValues=ldap_get_values(pLdap,pEntry,szAttribute); </code></pre> <p>and:</p> <pre><code>if (_tcscmp(szAttribute,TEXT("uUsnChanged"))==0) // uSNChanged is an example of an attribute pItemInfo-&gt;uUsnChanged=_tcstoui64(pszValues[0],NULL,10); // pItemInfo is a struct defined elsewhere to hold the results for any given entry </code></pre> <p>i looked on <a href="http://msdn.microsoft.com/en-us/library/ms679021(v=VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms679021(v=VS.85).aspx</a> to see if there is an attribute for 'pre windows 2000' login or something similar in the hope that I could just add this as another 'szAttribute' (to replace "uUsnChanged" in this example) and had no luck. Looking at the API i have been unable to come up with a way of getting this information.</p> <p>i found the attribute 'sAMAccountName' which i thought would provide the information needed but it only gives me the <strong>name</strong> part of the <strong>DOMAIN/name</strong> format. Typical, it's the other part i want!</p> <p>does anyone have any ideas on how to get the <strong>'pre windows 2000'</strong> string from 'pEntry'?</p> <p>@JPBlanc We are getting the correct nETBIOSName attribute now when running it on the test server. The app works on the assumption that there is a maximum of one nETBIOSName attribute per DC. It finds it by doing the following:</p> <p>gets the default host using <code>ldap_init(NULL,0)</code></p> <p>get the 'configuration naming context' using <code>ldap_search_s(pLdap,NULL,LDAP_SCOPE_BASE,NULL,pszAttrs,FALSE,&amp;pResults);</code> passing in the connection handle as the first parameter</p> <p>retrieves the 'configurationNamingContext' attribute using <code>ldap_get_values(pLdap,pEntry,TEXT("configurationNamingContext"));</code></p> <p>concatenates "CN=Partitions," to the beggining of the string giving something like "CN=Partitions,CN=Configuration,DC=domain,DC=com,DC=au"</p> <p>it then performs a search using <code>ldap_search_s(pLdap,szPartitionNC,LDAP_SCOPE_SUBTREE,TEXT("(nETBIOSName=*)"),pszAttrs,FALSE,&amp;pResults);</code></p> <p>then it loops through the results looking for anything with a 'nETBIOSName' attribute and once it finds one it breaks out of the loop and returns the value.</p> <p>Do you know if this is sufficient to work in any AD configuration?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COYour edit 1) Completely changes your question, making my earlier answer irrelevant and 2) Is nonsensical -- if all you want is the `DOMAIN` part of `DOMAIN\name`, then you **must** already have it or you wouldn't be able to make an LDAP connection in the first place...
      singulars
    2. COI was under the impression that the 'pre windows 2000 domain' could be different to the actual domain the active directory tree is on, it's with this in mind that I am attempting to get the pre windows 2000 domain name. I know very little about LDAP and have tried to glean as much as I can about the difference today. For example.... user logon name: user@something.somewhere.com.au... User logon name (pre-Windows 2000): SOMETHING\user... are you saying that the 'SOMETHING' in 'User logon name (pre-Windows 2000)' is neccessarily the same as the 'something' in the 'user logon name'?
      singulars
    3. CONo, the `SOMETHING` in `SOMETHING\user` is a netbios display name for a domain, and the `something.com.au` in `user@something.com.au` is a fully qualified domain name. But you need a domain name to connect to LDAP at all, at which point you either have the netbios name directly and used it to connect, or can trivially extract the netbios name from the fully qualified name with which you used to connect.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload