Re: ldap with nt4

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 01/25/05


Date: Tue, 25 Jan 2005 16:59:26 +0100

cornerman wrote:

> I have see a script dat sets a password for a user but i see
> ldap how can i use ldap with nt4???
Hi

You can't use LDAP in a NT4 domain, but you can use the WinNT
provider to do this:

'--------------------8<----------------------

Set oWshNet = CreateObject("WScript.Network")

strName = "user logon name here"

' If the computers are in another domain than the user you
' want to change, you will need to hard code the domain name
' the user belongs to in the variable "strNetBIOSDomain".
strNetBIOSDomain = oWshNet.UserDomain

On Error Resume Next
Set objUser = GetObject("WinNT://" & strNetBIOSDomain & "/" _
        & strName & ",user")

If Err.Number <> 0 Then
    On Error GoTo 0
    Wscript.Echo "User " & strName & " NOT found"
Else
    objUser.SetPassword strName
    objUser.SetInfo
    If Err.Number <> 0 Then
      On Error GoTo 0
      Wscript.Echo "Password NOT set for " & strName
    Else
      Wscript.Echo "Password set for " & strName
    End If
End If

'--------------------8<----------------------

-- 
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx


Relevant Pages

  • Re: Query AD for existence of a user account.
    ... I am using LDAP and can create new accounts, but obviously my script fails if an account with the same name already exists. ... On Error GoTo 0 ... torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.windows.server.scripting)
  • Re: 1000 result limit when quering AD in W2k3 w/ LDAP
    ... > Does anyone know how to diable the 1000 return result limit for LDAP ... ADO will only return the max values (a.k.a. 1000, or 1500 on Windows ... A paged search is transparent to your application because ADSI ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.windows.server.active_directory)
  • Re: Enquiry on ADSI user objects description
    ... > answer back as err: ... Spaces in the LDAP path is fully supported without needing to do ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.windows.server.scripting)
  • Re: Newbie : How to query a SAM (NT4) profile using System.DirectoryServices
    ... You can only use the WinNT provider if you are talking an NT4 domain. ... use LDAP, you must use Active Directory or another LDAP database. ... Joe K. ...
    (microsoft.public.dotnet.security)
  • Re: display the OU for a specific User
    ... Some info on LDAP vs. WinNT: ... Microsoft MVP Scripting and ADSI ... >> In general, when you have the distinguished name of the user object, you ...
    (microsoft.public.windows.server.scripting)