Get Netbios domain name from active directory

Discussion in 'Microsoft Windows 2000 Active Directory' started by jerome pesenti, Aug 4, 2006.

  1. Greetings,

    I am trying to accomplish a simple task but can't figure out if it's
    possible in active directory.

    A users log in into IIS and our application gets the NT login from the
    web server:

    MYDOMAIN\myuser

    >From this logon we would like to get the distinguished name of the

    user, like:

    cn=John User,dc=domain,dc=com

    I know that it's possible to do in VBScript (through the NameTranslate
    object) but our application tries to be portable and can only use LDAP
    requests to the Active Directory.

    It's possible to do a search for sAMAccountName=myuser but that may
    return muliple users from different domains and there doesn't seem to
    be any good way to match them back with the Netbios domain (MYDOMAIN)
    with complete certainty given that it may not be related at all with
    dc=domain,dc=com.

    Thanks for your help!
    Jerome
     
    jerome pesenti, Aug 4, 2006
    #1
    1. Advertisements

  2. jerome  pesenti

    Wayne Tilton Guest

    "jerome pesenti" <> wrote in
    news::

    > Greetings,
    >
    > I am trying to accomplish a simple task but can't figure out if it's
    > possible in active directory.
    >
    > A users log in into IIS and our application gets the NT login from the
    > web server:
    >
    > MYDOMAIN\myuser
    >
    >>From this logon we would like to get the distinguished name of the

    > user, like:
    >
    > cn=John User,dc=domain,dc=com
    >
    > I know that it's possible to do in VBScript (through the NameTranslate
    > object) but our application tries to be portable and can only use LDAP
    > requests to the Active Directory.
    >
    > It's possible to do a search for sAMAccountName=myuser but that may
    > return muliple users from different domains and there doesn't seem to
    > be any good way to match them back with the Netbios domain (MYDOMAIN)
    > with complete certainty given that it may not be related at all with
    > dc=domain,dc=com.
    >
    > Thanks for your help!
    > Jerome
    >
    >


    Here's a little subroutine that will get the NetBIOS name of the current
    user's AD domain (caution, it will wrap...):

    ' Returns the NetBIOS Domain Name of the users AD domain
    Function NTDomain
    Dim Partitions, Partition
    Set Partitions = GetObject("LDAP://CN=Partitions,CN=Configuration," &
    GetObject("LDAP://RootDSE").Get("DefaultNamingC
    ontext"))
    On Error Resume Next
    For Each Partition In Partitions
    NTDomain = Partition.Get("nETBIOSName")
    If Err.Number = 0 then Exit For
    Next
    End Function


    HTH,

    Wayne Tilton
     
    Wayne Tilton, Aug 4, 2006
    #2
    1. Advertisements

  3. Wayne Tilton wrote:
    > "jerome pesenti" <> wrote in
    > news::
    >
    > > Greetings,
    > >
    > > I am trying to accomplish a simple task but can't figure out if it's
    > > possible in active directory.
    > >
    > > A users log in into IIS and our application gets the NT login from the
    > > web server:
    > >
    > > MYDOMAIN\myuser
    > >
    > >>From this logon we would like to get the distinguished name of the

    > > user, like:
    > >
    > > cn=John User,dc=domain,dc=com
    > >
    > > I know that it's possible to do in VBScript (through the NameTranslate
    > > object) but our application tries to be portable and can only use LDAP
    > > requests to the Active Directory.
    > >
    > > It's possible to do a search for sAMAccountName=myuser but that may
    > > return muliple users from different domains and there doesn't seem to
    > > be any good way to match them back with the Netbios domain (MYDOMAIN)
    > > with complete certainty given that it may not be related at all with
    > > dc=domain,dc=com.
    > >
    > > Thanks for your help!
    > > Jerome
    > >
    > >

    >
    > Here's a little subroutine that will get the NetBIOS name of the current
    > user's AD domain (caution, it will wrap...):
    >
    > ' Returns the NetBIOS Domain Name of the users AD domain
    > Function NTDomain
    > Dim Partitions, Partition
    > Set Partitions = GetObject("LDAP://CN=Partitions,CN=Configuration," &
    > GetObject("LDAP://RootDSE").Get("DefaultNamingC
    > ontext"))
    > On Error Resume Next
    > For Each Partition In Partitions
    > NTDomain = Partition.Get("nETBIOSName")
    > If Err.Number = 0 then Exit For
    > Next
    > End Function
    >
    >
    > HTH,
    >
    > Wayne Tilton


    Thanks for the answer. I am actually not getting any nETBIOSname but
    the name field seems to be what I want. Unfortunately, as you show it
    in your code, there could be multiple partitions. In that case how
    would I know which one corresponds to the user logon domain?

    Jerome
     
    jerome pesenti, Aug 4, 2006
    #3
  4. jerome  pesenti

    Wayne Tilton Guest

    "jerome pesenti" <> wrote in
    news::

    >
    > Wayne Tilton wrote:
    >> "jerome pesenti" <> wrote in
    >> news::
    >>
    >> > Greetings,
    >> >
    >> > I am trying to accomplish a simple task but can't figure out if
    >> > it's possible in active directory.
    >> >
    >> > A users log in into IIS and our application gets the NT login from
    >> > the web server:
    >> >
    >> > MYDOMAIN\myuser
    >> >
    >> >>From this logon we would like to get the distinguished name of the
    >> > user, like:
    >> >
    >> > cn=John User,dc=domain,dc=com
    >> >
    >> > I know that it's possible to do in VBScript (through the
    >> > NameTranslate object) but our application tries to be portable and
    >> > can only use LDAP requests to the Active Directory.
    >> >
    >> > It's possible to do a search for sAMAccountName=myuser but that may
    >> > return muliple users from different domains and there doesn't seem
    >> > to be any good way to match them back with the Netbios domain
    >> > (MYDOMAIN) with complete certainty given that it may not be related
    >> > at all with dc=domain,dc=com.
    >> >
    >> > Thanks for your help!
    >> > Jerome
    >> >
    >> >

    >>
    >> Here's a little subroutine that will get the NetBIOS name of the
    >> current user's AD domain (caution, it will wrap...):
    >>
    >> ' Returns the NetBIOS Domain Name of the users AD domain
    >> Function NTDomain
    >> Dim Partitions, Partition
    >> Set Partitions =
    >> GetObject("LDAP://CN=Partitions,CN=Configuration," &
    >> GetObject("LDAP://RootDSE").Get("DefaultNamingC
    >> ontext"))
    >> On Error Resume Next
    >> For Each Partition In Partitions
    >> NTDomain = Partition.Get("nETBIOSName")
    >> If Err.Number = 0 then Exit For
    >> Next
    >> End Function
    >>
    >>
    >> HTH,
    >>
    >> Wayne Tilton

    >
    > Thanks for the answer. I am actually not getting any nETBIOSname but
    > the name field seems to be what I want. Unfortunately, as you show it
    > in your code, there could be multiple partitions. In that case how
    > would I know which one corresponds to the user logon domain?
    >
    > Jerome
    >
    >


    Jerome,

    I have managed to keep all of the forests I manage single domains, so I
    can't emulate your situation, but based on what I've seen, you should be
    able to do an LDAP search against the Partitions container in the
    Configuration naming context for an object that has netBIOSname set. Using
    Joe's great adfind.exe:

    adfind -config -rb cn=partitions -f netbiosname=* netbiosname

    should give you the netBIOSName of the logon users domain. If, due to
    multiple domains, etc., that doesn't work, I would think you could
    determine the search base by getting the users DN (via AdSystemInfo or NTO)
    and build the path: CN=Partitions,CN=Configuration,DC=users,DC=domain.

    Wayne
     
    Wayne Tilton, Aug 4, 2006
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ldapper2003

    different netbios domain name from AD domain

    ldapper2003, Oct 17, 2003, in forum: Microsoft Windows 2000 Active Directory
    Replies:
    2
    Views:
    189
    Joe Richards [MVP]
    Oct 19, 2003
  2. Guest

    Changing NETBIOS Domain Name of AD Domain Controller

    Guest, Aug 24, 2004, in forum: Microsoft Windows 2000 Active Directory
    Replies:
    1
    Views:
    1,204
    Steve
    Aug 24, 2004
  3. Brian Desmond [MVP]

    Re: Changing NETBIOS domain name when adding additonal Domain Controll

    Brian Desmond [MVP], Aug 26, 2004, in forum: Microsoft Windows 2000 Active Directory
    Replies:
    0
    Views:
    396
    Brian Desmond [MVP]
    Aug 26, 2004
  4. news.microsoft.com

    Windows 2000 Domain Renaming - NetBios Domain Name same as DNS Domain Name

    news.microsoft.com, Sep 29, 2004, in forum: Microsoft Windows 2000 Active Directory
    Replies:
    1
    Views:
    365
    Mark Ramey [MSFT]
    Sep 30, 2004
  5. RajKiran

    How important is Active Directory ? Cant we get rid of Active Directory ?

    RajKiran, Aug 10, 2007, in forum: Microsoft Windows 2000 Active Directory
    Replies:
    1
    Views:
    1,252
Loading...

Share This Page