Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Translation Name; Random Error

Status
Not open for further replies.

LBMCreation

Technical User
Jul 5, 2011
9
GB
Hi, I have a script which clears all users from groups located in a excel file.

The problem is that i have getting random errors stating:

Line 51
Char 2
Name translation; Could not find the name or insufficent right to see name
code: 80072116
SOurce: (null)

Sometimes it works and sometimes i get the above error.

any ideas why this is happening?

Here is my script

OPTION EXPLICIT

dim strFilter, strRoot, strScope, strGroupName, TimeNow, objWS
dim strNETBIOSDomain, strGroupDN, objSpread, DateNow, strFilePath, objFiletxt, objFSO
dim cmd, rs,cn, objGroup, strSheet, objExcel, intRow, wshShell, strTemp, objTempMessage, strWindowTitle, strTempVBS, objProgressMsg
Const ForReading = 1
Const OpenAsASCII = 0
Const ADS_PROPERTY_CLEAR = 1

strWindowTitle = "Running LMS Delete Script"
ProgressMsg "Deleting Users From Groups, Please wait.", strWindowTitle

strSheet = "C:\EXCELSCRIPT\EXCELFILE.xlsm"
Set objExcel = CreateObject("Excel.Application")
Set objSpread = objExcel.Workbooks.Open(strSheet)
Wscript.Sleep 3000
Set objWS = objExcel.ActiveWorkBook.WorkSheets("Delete")
intRow = 2

Do Until objExcel.Cells(intRow,1).Value = ""
strGroupName = Trim(objExcel.Cells(intRow, 1).Value)
intRow = intRow + 1
strNETBIOSDomain = "REALDOMAINHIDDEN"

strGroupDN = GetDN(strNETBIOSDomain,strGroupName)

set objGroup = getobject("LDAP://" & strGroupDN)
objGroup.PutEx ADS_PROPERTY_CLEAR, "member", 0
objGroup.SetInfo
Wscript.Sleep 1000
Loop

ProgressMsg "", strWindowTitle
strWindowTitle = ""
ObjExcel.Quit
Wscript.Sleep 10000
run "LMS_AddToGroups.vbs"

Function GetDN(byval strDomain,strObject)
DIM objTrans

Set objTrans = CreateObject("NameTranslate")
objTrans.Init 1, strDomain
objTrans.Set 3, strDomain & "\" & strObject
GetDN = objTrans.Get(1)

end function

' Progress MSG

Function ProgressMsg( strMessage, strWindowTitle )
Set wshShell = WScript.CreateObject( "WScript.Shell" )
strTEMP = wshShell.ExpandEnvironmentStrings( "%TEMP%" )
If strMessage = "" Then
On Error Resume Next
objProgressMsg.Terminate( )
On Error Goto 0
Exit Function
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
strTempVBS = strTEMP + "\" & "Message.vbs"

Set objTempMessage = objFSO.CreateTextFile( strTempVBS, True )
objTempMessage.WriteLine( "MsgBox""" & strMessage & """, 4096, """ & strWindowTitle & """" )
objTempMessage.Close

On Error Resume Next
objProgressMsg.Terminate( )
On Error Goto 0

Set objProgressMsg = WshShell.Exec( "%windir%\system32\wscript.exe " & strTempVBS )

Set wshShell = Nothing
Set objFSO = Nothing
End Function

Sub Run(ByVal sFile)
Dim shell

Set shell = CreateObject("WScript.Shell")
shell.Run Chr(34) & sFile & Chr(34), 1, false
Set shell = Nothing
End Sub

EXCEL FILE:

COL A
Header
Group1
Group2
Group3
Group4
Group5
 
any ideas? i am now also getting random server not operational errors too :/
 
What is the purpose of your script. That might help put context with the error.

-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
the main goal of the script is to delete all members of a group. it finds the groups from the xlsm file col A

example: it gets group A from ColA Row2 and deletes all members of that group and move onto the next one in the xlsm file
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top