Windows Vista Forums

Check if user defined in SD

  1. #1


    Mad Mark Guest

    Check if user defined in SD

    Hi,

    How would you check if a specific user given to you exists anywhere in the
    domain please?

    E.G user id is xxx123456 You want to see if that user is defined or not, if
    defined get information. The user may be in a number of unknown and
    different OU's.

    Many thanks

    Mark



      My System SpecsSystem Spec

  2. #2


    Richard Mueller [MVP] Guest

    Re: Check if user defined in SD

    Mark wrote:

    >
    > How would you check if a specific user given to you exists anywhere in the
    > domain please?
    >
    > E.G user id is xxx123456 You want to see if that user is defined or not,
    > if defined get information. The user may be in a number of unknown and
    > different OU's.
    Assuming the user id you have is the "pre-Windows 2000 logon" name, you can
    use the NameTranslate object in a VBScript program to convert this (with the
    NetBIOS name of the domain) to the Distinguished Name (DN). The DN indicates
    where in the hierarchy of AD the object resides. For more on NameTranslate
    see this link:

    http://www.rlmueller.net/NameTranslateFAQ.htm

    The quick example (#6) shows how to do it. If the user does not exist an
    error is raised by the Set method. If desired, you could trap this error.
    For example:
    =============
    ' Constants for the NameTranslate object.
    Const ADS_NAME_INITTYPE_GC = 3
    Const ADS_NAME_TYPE_NT4 = 3
    Const ADS_NAME_TYPE_1779 = 1

    ' Specify the NetBIOS name of the domain and the NT name of the user.
    strNTName = "MyDomain\TestUser"

    ' Use the NameTranslate object to convert the NT user name to the
    ' Distinguished Name required for the LDAP provider.
    Set objTrans = CreateObject("NameTranslate")

    ' Initialize NameTranslate by locating the Global Catalog.
    objTrans.Init ADS_NAME_INITTYPE_GC, ""
    ' Use the Set method to specify the NT format of the object name.
    ' Trap error if user does not exist.
    On Errro Resume Next
    objTrans.Set ADS_NAME_TYPE_NT4, strNTName
    If (Err.Number = 0) Then
    On Error GoTo 0

    ' Use the Get method to retrieve the RPC 1779 Distinguished Name.
    strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)

    Wscript.Echo strUserDN
    Else
    On Error GoTo 0
    Wscript.Echo "User " & strNTName & " does not exist"
    End If

    --
    Richard Mueller
    MVP Directory Services
    Hilltop Lab - http://www.rlmueller.net
    --



      My System SpecsSystem Spec

  3. #3


    Al Dunbar Guest

    Re: Check if user defined in SD


    "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in
    message news:%231f6x9xHJHA.1308@xxxxxx

    > Mark wrote:
    >

    >>
    >> How would you check if a specific user given to you exists anywhere in
    >> the domain please?
    >>
    >> E.G user id is xxx123456 You want to see if that user is defined or not,
    >> if defined get information. The user may be in a number of unknown and
    >> different OU's.
    >
    > Assuming the user id you have is the "pre-Windows 2000 logon" name, you
    > can use the NameTranslate object in a VBScript program to convert this
    > (with the NetBIOS name of the domain) to the Distinguished Name (DN). The
    > DN indicates where in the hierarchy of AD the object resides. For more on
    > NameTranslate see this link:
    >
    > http://www.rlmueller.net/NameTranslateFAQ.htm
    >
    > The quick example (#6) shows how to do it. If the user does not exist an
    > error is raised by the Set method. If desired, you could trap this error.
    > For example:
    > =============
    > ' Constants for the NameTranslate object.
    > Const ADS_NAME_INITTYPE_GC = 3
    > Const ADS_NAME_TYPE_NT4 = 3
    > Const ADS_NAME_TYPE_1779 = 1
    >
    > ' Specify the NetBIOS name of the domain and the NT name of the user.
    > strNTName = "MyDomain\TestUser"
    >
    > ' Use the NameTranslate object to convert the NT user name to the
    > ' Distinguished Name required for the LDAP provider.
    > Set objTrans = CreateObject("NameTranslate")
    >
    > ' Initialize NameTranslate by locating the Global Catalog.
    > objTrans.Init ADS_NAME_INITTYPE_GC, ""
    > ' Use the Set method to specify the NT format of the object name.
    > ' Trap error if user does not exist.
    > On Errro Resume Next
    > objTrans.Set ADS_NAME_TYPE_NT4, strNTName
    > If (Err.Number = 0) Then
    > On Error GoTo 0
    >
    > ' Use the Get method to retrieve the RPC 1779 Distinguished Name.
    > strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)
    >
    > Wscript.Echo strUserDN
    > Else
    > On Error GoTo 0
    > Wscript.Echo "User " & strNTName & " does not exist"
    > End If
    Or, alternately, you could use a simple batch script with a command such as:

    net user /domain xxx123456

    /Al



      My System SpecsSystem Spec

Check if user defined in SD

Similar Threads
Thread Forum
Need help:Charmap doesn't display user-defined fonts
Hi, I'm having a problem with charmap.exe. While it is working perfectly on both Windows XP and Windows Vista 32 Bit, it does not include "All...
Vista performance & maintenance
User-defined characters in 64 Bit Vista?
Hi, I'm currently trying to create user-defined characters in Vista 64 Bit using the private character editor (eudcedit.exe). I can create...
General Discussion
Re: User defined functions.
Il giorno Fri, 17 Jul 2009 23:22:52 -0600, "Al Dunbar" <alandrub@xxxxxx> ha scritto: Thanks for your reply. Giovanni -- Giovanni Cenati...
VB Script
Re: Check if user is already in AD
"jmakarius" <jmakarius@xxxxxx> wrote in message news:C027667B-D972-474E-BABC-F6CB9B693D1F@xxxxxx There must be a way to do this in powershell, as...
PowerShell
How do I set User Right on Bypass traverse checking to 'Not Defined'?
Is it possible to set User Rights - Bypass Traverse Checking to Not Defined? This User right is assigned by default to accounts: Everyone,...
Vista security
User-defined sorting
Is it possible to create a user-defined field that will allow me to custom-sort my picture directories? I've got lots of photos and videos of my...
Vista file management
How to bind a Trigger to a user defined DependencyProperty
Hi I do the following inside my code public partial class ShoppingCart : StackPanel, INotifyPropertyChanged { public ShoppingCart() {...
Avalon