How to get domain\username (NT account) from a DirectoryEntry object of user?
From: Shan McArthur (shan_mcarthur@spamcop.net)
Date: 02/14/03
- Next message: RP: "Re: using p12 Certificate - converting to x509 What am I doing wrong?"
- Previous message: Michel Gallant (MVP): "Re: using p12 Certificate - converting to x509 What am I doing wrong?"
- Next in thread: Joe Kaplan: "Re: How to get domain\username (NT account) from a DirectoryEntry object of user?"
- Reply: Joe Kaplan: "Re: How to get domain\username (NT account) from a DirectoryEntry object of user?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: "Shan McArthur" <shan_mcarthur@spamcop.net> Date: Thu, 13 Feb 2003 19:25:37 -0600
Hello,
I have DirectoryEntry object for a user (using the LDAP provider and
distinguished name) and I need to get the NT username for this user in a
reliable way. For example, I need to resolve the DOMAIN\USERNAME string for
this user account. I can retrieve the username by reading the
sAMAccountName attribute, but this does not include the domain name. My
concern is that if my code is running on a member server, using just the
username with LogonUser() will result in failed authentication attempts
against the local security database. I know it will work if I add the
domain, but I do not know how to detect the domain based on the
DirectoryEntry handle on the user. I need this code to work in multiple
domains so I do not want to hard code a domain name. The code should work
in Mixed or Native active directory mode. It should also work if the active
directory DC container is named different than the NT domain name. Finally,
it needs to work on a member server as well as a domain controller.
I would prefer a native .NET way to do this. The only approach I know of is
to export a wrapper on top of activeds.dll and use the name translate COM
object. I want to avoid having to distribute a custom wrapper DLL with my
executable, as who-knows, microsoft may change the underlying activeds.dll
in a manner that will break the wrapper.
Any other ideas for how to reliably get the domain name out of active
directory?
Thanks,
Shan McArthur
- Next message: RP: "Re: using p12 Certificate - converting to x509 What am I doing wrong?"
- Previous message: Michel Gallant (MVP): "Re: using p12 Certificate - converting to x509 What am I doing wrong?"
- Next in thread: Joe Kaplan: "Re: How to get domain\username (NT account) from a DirectoryEntry object of user?"
- Reply: Joe Kaplan: "Re: How to get domain\username (NT account) from a DirectoryEntry object of user?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|