PC Review


Reply
Thread Tools Rate Thread

Get Netbios domain name from active directory

 
 
jerome pesenti
Guest
Posts: n/a
 
      4th Aug 2006
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

 
Reply With Quote
 
 
 
 
Wayne Tilton
Guest
Posts: n/a
 
      4th Aug 2006
"jerome pesenti" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> 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
 
Reply With Quote
 
 
 
 
jerome pesenti
Guest
Posts: n/a
 
      4th Aug 2006

Wayne Tilton wrote:
> "jerome pesenti" <(E-Mail Removed)> wrote in
> news:(E-Mail Removed):
>
> > 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

 
Reply With Quote
 
Wayne Tilton
Guest
Posts: n/a
 
      4th Aug 2006
"jerome pesenti" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

>
> Wayne Tilton wrote:
>> "jerome pesenti" <(E-Mail Removed)> wrote in
>> news:(E-Mail Removed):
>>
>> > 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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows 2000 Domain Renaming - NetBios Domain Name same as DNS Domain Name news.microsoft.com Microsoft Windows 2000 DNS 1 30th Sep 2004 10:59 PM
Windows 2000 Domain Renaming - NetBios Domain Name same as DNS Domain Name news.microsoft.com Microsoft Windows 2000 Active Directory 1 30th Sep 2004 10:59 PM
Re: Changing NETBIOS domain name when adding additonal Domain Controll Brian Desmond [MVP] Microsoft Windows 2000 Active Directory 0 26th Aug 2004 04:20 AM
Changing NETBIOS Domain Name of AD Domain Controller =?Utf-8?B?Z21pY2tlbHNlbg==?= Microsoft Windows 2000 Active Directory 1 24th Aug 2004 01:10 PM
different netbios domain name from AD domain ldapper2003 Microsoft Windows 2000 Active Directory 2 19th Oct 2003 01:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:31 AM.