Re: How to import hierarchy data into AD




"Marcus" <Marcus@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:EE46CC4B-0CD5-480B-A08D-5A91EC16A5E9@xxxxxxxxxxxxxxxx
Great!

My file would be like this:

Manager; Report 1; Report 2;

Is it possible to use the User ID (Pre-Windows 2000) instead of the DN?

You can use the NameTranslate object to convert pre-Windows 2000 names to
DN's. Also with semicolon delimiters it will be much easier to parse each
line, assuming no values have embedded semicolons. My earlier program
becomes:
============
Option Explicit

Dim strFile, objFSO, objFile, strLine, strItem, strManager, objReport
Dim objTrans, strNetBIOSDomain, objRootDSE, strDNSDomain, strReport
Dim arrValues

Const ForReading = 1

' 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 text file.
strFile = "c:\scripts\organization.csv"

' Determine DNS name of domain from RootDSE.
Set objRootDSE = GetObject("LDAP://RootDSE";)
strDNSDomain = objRootDSE.Get("defaultNamingContext")

' Use the NameTranslate object to find the NetBIOS domain name from the
' DNS domain name.
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_INITTYPE_GC, ""
objTrans.Set ADS_NAME_TYPE_1779, strDNSDomain
strNetBIOSDomain = objTrans.Get(ADS_NAME_TYPE_NT4)
' Remove trailing backslash.
strNetBIOSDomain = Left(strNetBIOSDomain, Len(strNetBIOSDomain) - 1)

' Open the text file for read access.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFile, ForReading)

' Read each line of the file.
Do Until objFile.AtEndOfStream
strLine = Trim(objFile.ReadLine)
' Skip blank lines.
If (strLine <> "") Then
' First determine the manager DN.
strManager = ""
arrValues = Split(strLine, ";")
For Each strItem In arrValues
' The first DN on the line is that of the manager.
If (strManager = "") Then
' Use the Set method to specify the NT format of the manager
name.
' Trap error if user does not exist.
On Error Resume Next
objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" &
strItem
If (Err.Number <> 0) Then
On Error GoTo 0
Wscript.Echo "Manager " & strItem & " not found."
' No need to deal with reports if manager unknown.
Exit For
Else
On Error GoTo 0
' Use the Get method to retrieve the RPC 1779
Distinguished Name.
strManager = objTrans.Get(ADS_NAME_TYPE_1779)
End If
Else
' All subsequent DN's are of direct reports.
' Use the Set method to specify the NT format of the
report's name.
' Trap error if user does not exist.
On Error Resume Next
objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" &
strItem
If (Err.Number <> 0) Then
On Error GoTo 0
Wscript.Echo "Direct report " & strItem & " not found."
Else
On Error GoTo 0
' Use the Get method to retrieve the RPC 1779
Distinguished Name.
strReport = objTrans.Get(ADS_NAME_TYPE_1779)
' Bind to direct report user object.
Set objReport = GetObject("LDAP://"; & strReport)
' Assign manager DN.
objReport.manager = strManager
' Save changes.
objReport.SetInfo
End If
End If
Next
End If
Loop

' Clean up.
objFile.Close

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


.



Relevant Pages

  • Re: Portage, WI: FLorida DCF Link to case -- bad handling
    ... TALLAHASSEE - Fresh from serving time in a Colorado prison on fraud charges, Candice Clark returned to living with her daughter, Courtney, last August despite orders from a case manager that mother and child were not to be left alone. ... Such are the findings in a report by the state contractor entrusted with the welfare of Courtney Clark, a Pinellas County foster child who turned up with her mother this month at the site of a gruesome crime scene in Wisconsin. ...
    (alt.true-crime)
  • Re: Unable to save ...copy...report --- code: Document Objects
    ... There are also general Report properties that are not set up in the Objex and Ctrlz tables. ... On Error GoTo Proc_Err ... Dim mStr As String _ ...
    (microsoft.public.access.modulesdaovba)
  • Minutes of RSGB Board Meeting 19 January 2008
    ... Peter Kirby G0TWW General Manager ... The President, Colin Thomas G3PSM, opened the meeting and welcomed the ... Pathfinder Group Interim Report previous item 3.1.5. ...
    (uk.radio.amateur)
  • Announcement: DICOM Archive dcm4chee-2.8.2 now available for download
    ... Performed Procedure Step Manager ... Simple Image and Numeric Report (SINR) ... Post-Processing Workflow (PWF) ... Patient Identifier Cross-referencing (PIX) ...
    (comp.protocols.dicom)
  • RE: ServiceBase denies access to service name
    ... I encourage you to report this issue to ... Microsoft Online Community Support ... Delighting our customers is our #1 priority. ... You can send feedback directly to my manager at: ...
    (microsoft.public.dotnet.framework)

Quantcast