Das Notes Forum
Domino 9 und frühere Versionen => ND6: Entwicklung => Thema gestartet von: robertpp am 02.08.05 - 15:55:59
-
Ich hab ein vbs Script das mir leider ( aber verständlicherweise) einen Fehler ausgibt. In vbs funktioniert es aber wunderbar nur LS nicht. Meinen Frage ist jetzt wie kann ich den Fehler umgehen?
Const ComputerName = "srveb01"
Const domain = "//ATEBD1"
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set db = s.CurrentDatabase
Set UserName = GetObject("WinNT://" & ComputerName & ",computer")
UserName.Filter = Array("User") ' hier tritt der Fehler immer auf
Forall users In UserName
On Error Resume Next
user = users.Name
Set oUser = GetObject("WinNT:" & domain & "/" & user)
Set doc = db.CreateDocument
doc.Form = "activedirectory"
doc.ShortName = oUser.Name
doc.FullName = oUser.FullName
doc.Department =oUser.Description
doc.LastLogin = oUser.LastLogin
If oUser.AccountDisabled <> False Then
doc.AccountDisabled = "True"
End If
If oUser.IsAccountLocked <> False Then
doc.AccountLocked = "True"
End If
doc.ValidFrom = Int(oUser.PasswordAge/3600/24)
Call doc.Save(True, False)
End Forall
Ich hab auch schon anstelle von:
Set UserName = GetObject("WinNT://" & ComputerName & ",computer")
das hier gemacht
Set UserName= GetObject("winmgmts:\\" & ComputerName & "\root\cimv2").InstancesOf("Win32_UserAccount")
das geht auch aber liefert mir ein anderes Ergebnis mit dem nicht wirklich etwas anfangen kann.
-
Was ist das "Array("User")" für ein Konstrukt? in LS gibts doch gar keine Array() funktion.
Was erwartet den Username.Filter für einen Datentyp?
gruss
umi
-
Ich weiß leider nicht wie es anders gehen soll. Ich hab im Praxisbuch von Tobias Weltner "Scripting für Admins" gesehen das das es dort ebenfalls mit
domain.Filter = Array("User") gemacht wird und dort passt es auch!
http://www.microsoft.com/technet/scriptcenter/guide/sas_ads_zjvb.mspx
Listing 5.56 Displaying the Filtered Property
oder hier noch ein Microsoft Script
-
Ich hab auch im Forum das
http://www.atnotes.de/index.php?topic=18372.msg112125#msg112125
gefunden. Ich weiß aber nicht ob es damit zu tun hat.
-
Ich denke es liegt am Array("Users"). Dies ist ein Objekt welches LS nicht kennt. in VBs ist es wahrscheinlich vorhanden.
Was für ein Fehler gibts Notes den Retour?
-
Der Fehler tritt schon beim Speichern vom Script auf:
Illegal parenthesized reference: ARRAY
Ich hab das jetzt auch schon probiert:
UserName.Filter = "User"
nur das ist im völlig egal da bekomme ich das Ergebnis wie wenn ich die Zeile nicht geschrieben hätte.
Vielleicht gibt es sonst noch eine Möglichkeit alle user aus der Domaine auszulesen sollte das nicht gehen?
-
evtl hilft ja folgendes
dim userarray(1) as string
...
...
userarray(0) = "User"
...
...
UserName.filter=userarray
...
-
Meiner Meinung nach kennt er schon das hier warscheinlich nicht.
Set UserName = GetObject("WinNT://" & ComputerName & ",computer")
Schau doch mal im Debugger nach ob er das Object überhaupt zuweist.
-
In der KBASE gibt es ein Hinweis zu einem ähnlichen Problem:
Title:
Using a Method For a Non-Lotus Object Results in the Error: Automation Object Member Not Found
Product: Lotus Notes > Lotus Notes > Versions 6.x, 5.x
Platform(s): Platform Independent
Date: 25.11.2004
Doc Number: 1085124
Problem
LotusScript code that accesses a third party object (a non-Lotus object) results in the following error when calling methods which contain no parameters:
"Automation object member not found."
The same code logic works within Visual Basic without error.
The following code sample demonstrates this issue. The below code runs on Windows systems to access the Assigned Directories Services (ASDi) object. When the Members method is called, the error occurs:
Dim Group
Dim Member
' Bind to a known group object.
Set Group = GetObject("WinNT://ComputerName/Administrators")
Set member = Group.Members 'The code will error when executing this line
Forall x In member
Print x.name
End Forall
Msgbox group.name ' Returns "Administrators"
Msgbox group.class ' Returns "Group"
Msgbox group.AdsPath ' Returns "WinNT://Domain/ComputerName"
If Group.IsMember("WinNT://Domain/ComputerName/csmith") Then
Msgbox "Already a Member"
Else
group.Add("WinNT://ComputerName/csmith")
End If
Solution
LotusScript requires the use of parentheses when calling the methods of non-Lotus objects, even when the methods do not have any parameters.
From the example above, the Members method call would be made as follows:
Set member = Group.Members()
Within Notes, when working with Notes objects it is recommended, but not required, to use parentheses when calling a method that does not contain any parameters.
For example, both of the following calls to GetFirstDocument (of the NotesDocumentCollection class) run without error:
Set doc = collection.getfirstdocument
Set doc = collection.getfirstdocument()
Supporting Information:
A directory service is basically a database that contains the attributes and locations of shared objects connecting the network. Users that want to access these resources may do so by using a special syntax. An assigned directory service uses a syntax which is called a namespace. For example, //CompanyName/csmith would identify a workstation and a logged-in user. The collection of all workstations and users on the network can be accessed this way from a namespace. A directory service provides a method to manage the data stored in internal tables. You can read and set security flags and descriptions.
The ability to access and/or update the Active Directories depends on the ADSi object control and is available through COM.
It is also important when using the IsMember method, that the complete ADsPath is used.
Related Documents:
Setting Third-Party Object Property to an Object Causes Error: "Automation Object Member Not Found"
Document #: 1084270
Wichtig sind also die Klammern!
Andreas
-
Andreas, das kennt Robert schon - darauf hat er selber verwiesen, und auch das war ein Artikel von Dir ;)
Bernhard
-
Wenn man das zum Fliegen bringt, sehe ich aber immer noch ein Problem: Was ist, wenn es in der Domäne zu viele User gibt, um sie in einem Array abzulegen ? Dieses ist ja arg endlich mit seiner Speicherkapazität ...
Leider fallen mir aber derzeit keine alternativen Möglichkeiten ein, um die User auszulesen.
Bernhard
-
Hallo nach eine kurzen Pause retour.
@thomas: Das Script läuft bereits aber es liefert mir ein anderes Ergebnis weil ich das Filtern auf "User" nicht durchführen kann.
Das heisst ich denke an dem kann es nicht liegen:
Set UserName = GetObject("WinNT://" & ComputerName & ",computer")
@Andreas: hab ich schon gelesen wie Bernhard es auch schon gesagt hat aber ich denke es könnte der richtige Weg sein aber wie weiß ich (noch) nicht!
@Bernhard: ich lege die user ja nicht in ein Array sondern ich erzeuge gleich für jeden user ein doc.
Ich denke dieser Befehl:
UserName.Filter = Array("User")
filtert einfach aus dem UserName alle einträge die ein "User" sind.
robert
-
Also es ist:
IADsContainer Property
The one read-only property in IADsContainer lets you read the object classes specified in the Filter method.
• IADsContainer::Filter. This property returns the class of objects being filtered in a container enumeration.
IADsContainer::Filter is also considered a method because you use it to set the Filter property on a container object to be enumerated. Therefore, to separate the property from the method, the property is referred to as get_Filter because it reads the value of the filter. The method is referred to as put_Filter because it sets or writes the value of the filter.
Array erstellt auf einfache Weise in VB ein Array. Du brauchst aber kein Array. Also müsste es so gehen:
Const ComputerName = "srveb01"
Const domain = "//ATEBD1"
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set db = s.CurrentDatabase
dim UserName as variant
Set UserName = GetObject("WinNT://" & ComputerName & ",computer")
UserName.Filter = "User"
Forall users In UserName
On Error Resume Next
user = users.Name
Set oUser = GetObject("WinNT:" & domain & "/" & user)
Set doc = db.CreateDocument
doc.Form = "activedirectory"
doc.ShortName = oUser.Name
doc.FullName = oUser.FullName
doc.Department =oUser.Description
doc.LastLogin = oUser.LastLogin
If oUser.AccountDisabled <> False Then
doc.AccountDisabled = "True"
End If
If oUser.IsAccountLocked <> False Then
doc.AccountLocked = "True"
End If
doc.ValidFrom = Int(oUser.PasswordAge/3600/24)
Call doc.Save(True, False)
End Forall
-
Hallo Andreas,
Das hab ich auch schon ausprobiert hat dann keinen fehler mehr ausgegeben jedoch nicht das gleiche Ergebnis geliefert es haben dann immer einig User gefehlt was mir jedoch unerklärlich war.
-
Hat niemand mehr eine Idee wie ich mein UserName.Filter = Array("User") zum laufen bekomme?
Ich hab hier jetzt nochmals eine unterschied bemerkt:
Getestet mit vbs-Script
DisplayObjects "LDAP://atebd1", ""
Function DisplayObjects( strADsPath, strSpace)
set objObject = GetObject(strADsPath)
Wscript.Echo strSpace & strADsPath
objObject.Filter = Array("organizationalUnit")
for each objChildObject in objObject
DisplayObjects objChildObject.ADsPath, strSpace & " "
next
End Function
Liefert mir alle OU einer Domain. ( EDV, PER, FE,... usw)
Gegensatz:
DisplayObjects "LDAP://atebd1", ""
Function DisplayObjects( strADsPath, strSpace)
set objObject = GetObject(strADsPath)
Wscript.Echo strSpace & strADsPath
objObject.Filter = "organizationalUnit"
for each objChildObject in objObject
DisplayObjects objChildObject.ADsPath, strSpace & " "
next
End Function
Hingegen liefert mir das Script alle Einträge aus dem AD. ( User Groups, Computer,....usw.) das heisst er ignoriert diesen Eintrag.
Das heisst ich muss es irgendwie hinbekommen es mit Array zu machen.
Vielleicht weiß ja jemand ob das "User" oder "organizationalUnit" im Active Directory in einem Feld steht auf das man abfragen kann.
-
Versuch mal folgendes:
Function DisplayObjects( strADsPath, strSpace)
dim array_filter(0) as string
array_filter(0) = "User"
set objObject = GetObject(strADsPath)
Wscript.Echo strSpace & strADsPath
objObject.Filter = array_filter
for each objChildObject in objObject
DisplayObjects objChildObject.ADsPath, strSpace & " "
next
End Function
Das sollte eigentlich analog Array("User") funktionieren, wenn ich die Funktion Array richtig verstehe.
Andreas
-
Tut leider auch nichts:
Bring folgendes Ergebnis:
"LDAP://atebd1/OU=0_Deakt,DC=atebg1,DC=int" <--- Ist eine OU
nächter Durchlauf:
"LDAP://atebd1/CN=APareja,OU=0_Deakt,DC=atebg1,DC=int" <---- ist ein User
dann wieder:
"LDAP://atebd1/OU=0_Deakt,DC=atebg1,DC=int" <--- eine OU
und wieder ein:
"LDAP://atebd1/CN=bah,OU=0_Deakt,DC=atebg1,DC=int" <---- neuer User
Mittlerweile hab ich schon vier Möglichkeiten getestet und keines brachte das selber Ergebnis wie das vbs-Script.
-
Anstelle des Filters kann Du auch über alle Objekte iterieren und die Klasse abfragen, wie bspw. hier beschrieben
http://www.serverwatch.com/tutorials/print.php/1548191
Also irgendwie so
Const ComputerName = "srveb01"
Const domain = "//ATEBD1"
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set db = s.CurrentDatabase
dim UserName as variant
Set UserName = GetObject("WinNT://" & ComputerName & ",computer")
Forall object in UserName
If object.class = "User" Then
On Error Resume Next
user = object.Name
Set oUser = GetObject("WinNT:" & domain & "/" & user)
Set doc = db.CreateDocument
doc.Form = "activedirectory"
doc.ShortName = oUser.Name
doc.FullName = oUser.FullName
doc.Department =oUser.Description
doc.LastLogin = oUser.LastLogin
If oUser.AccountDisabled <> False Then
doc.AccountDisabled = "True"
End If
If oUser.IsAccountLocked <> False Then
doc.AccountLocked = "True"
End If
doc.ValidFrom = Int(oUser.PasswordAge/3600/24)
Call doc.Save(True, False)
End if
End Forall
Andreas
-
Andreas ich muss sagen ich bin erleichtert. Es hat mir 1 1/2 Tage gekostet aber genau das hab ich gesucht.
Ich hab einiges über objectClass: user gefunden aber nicht genau gewusst wie es gehen könnte. ;D ;D :D
DANKE
Zur Info: Es ist für eine db die alle Benutzer beinhält mit Fotos und sonstigen IT-Zugriffen(für Dokumentation) und jetzt kommt noch die Info Alter Pwd, Benutzername, Fullname, Lastlogin = alles vom AD und gleichzeitig kann man user die sich nach x fehlversuchen sich anzumelden gesperrt haben wieder entsperren oder auch disablen.
-
Noch als Ergänzung:
Eine Möglichkeit gibt es noch die aber für mich nicht befriedigend war: (weil ich eben diese Info hatte: "objectClass: user" )
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set db = s.CurrentDatabase
Set MyUserContainer =GetObject("WinNT://srveb09")
Forall oUser In MyUserContainer
If oUser.Name ="Gäste" Then
Exit Forall
End If
Set doc = db.CreateDocument
doc.Form = "activedirectory"
doc.ShortName = oUser.Name
doc.FullName = oUser.FullName
doc.Department =oUser.Description
' doc.LastLogin = oUser.LastLogin
If oUser.AccountDisabled <> False Then
doc.AccountDisabled = "True"
End If
If oUser.IsAccountLocked <> False Then
doc.AccountLocked = "True"
End If
doc.ValidFrom = Int(oUser.PasswordAge/3600/24)
Call doc.Save(True, False)
End Forall
Hier bekomm ich aber leider nicht das Lastlogin retour.
Das Script ist so das es alle Einträge einlist.
Aus dem AD kommen die Einträge so:
user
user
user
user
user
usw.
Gäste -User
Abteilung
Abteilung
Abteilung
usw.
Computer
Computer
usw.
Und somit hab ich einfach bis zu dem User Gäste abgefragt und dann beendet.