Vaeb Posted April 3, 2008 Posted April 3, 2008 Hi guys! I would like to read the Attribute "Location" of a printer. This is how my script looks: expandcollapse popup; _ADGetObjectAttribute ; Retrieves the specified (single-value) attribute for the given SamAccountName ; Returns 0 if the object does not exist, the attribute does not exist for that ; object or if the value is multi-string. ; Otherwise returns the result Dim $objConnection Dim $strHostServer Dim $strDNSDomain $object = "PNMarketingC22PCL" $attribute = "Location" MsgBox(0,"klsda","Result: " & _ADGetObjectAttribute($object,$attribute)) Func _ADGetObjectAttribute($object, $attribute) If _ADObjectExists($object) = 0 Then Return 0 $strHostServer = "server27" $strDNSDomain = "CN=PVSVPS001" $strQuery = "<LDAP://" & $strHostServer & "/" & $strDNSDomain & ">;(sAMAccountName=" & $object & ");ADsPath;subtree" $objRecordSet = $objConnection.Execute ($strQuery) ; Retrieve the FQDN for the object $ldap_entry = $objRecordSet.fields (0).value $oObject = ObjGet($ldap_entry) ; Retrieve the COM Object for the object $result = $oObject.Get ($attribute) $oObject.PurgePropertyList $oObject = 0 If $result = "" Then Return "" Else Return $result EndIf EndFunc ;==>_ADGetObjectAttribute Func _ADObjectExists($object) $strQuery = "<LDAP://" & $strHostServer & "/" & $strDNSDomain & ">;(sAMAccountName=" & $object & ");ADsPath;subtree" $objRecordSet = $ObjConnection.Execute ($strQuery) ; Retrieve the FQDN for the group, if it exists If $objRecordSet.RecordCount = 1 Then $objRecordSet = 0 Return 1 Else $objRecordSet = 0 Return 0 EndIf EndFunc ;==>_ADObjectExists When I start, I get this error: H:\AutoIt\Printer\AD_read_prop.au3 (39) : ==> Variable must be of type "Object".: $objRecordSet = $ObjConnection.Execute ($strQuery) $objRecordSet = $ObjConnection^ ERROR Greets Vaeb I <3 it:http://www.autoitscript.com/forum/index.php?showtopic=69912http://www.autoitscript.com/forum/index.php?showtopic=69914http://www.autoitscript.com/forum/index.php?showtopic=69911
Vaeb Posted April 3, 2008 Author Posted April 3, 2008 What have i got to write into the ObjGet function? $objConnection = ObjGet("LDAP://server") I <3 it:http://www.autoitscript.com/forum/index.php?showtopic=69912http://www.autoitscript.com/forum/index.php?showtopic=69914http://www.autoitscript.com/forum/index.php?showtopic=69911
DarkMatter Posted April 3, 2008 Posted April 3, 2008 (edited) Have you tried using ObjCreate instead of ObjGet? Edited April 3, 2008 by DarkMatter [sub]Quantum mechanics: The dreams stuff is made of[/sub]
Vaeb Posted April 4, 2008 Author Posted April 4, 2008 The problem is: I really don't know, what to write as "filename" or "classname". Can anyone please make an example? I really don't get it... I <3 it:http://www.autoitscript.com/forum/index.php?showtopic=69912http://www.autoitscript.com/forum/index.php?showtopic=69914http://www.autoitscript.com/forum/index.php?showtopic=69911
Vaeb Posted April 17, 2008 Author Posted April 17, 2008 meow I <3 it:http://www.autoitscript.com/forum/index.php?showtopic=69912http://www.autoitscript.com/forum/index.php?showtopic=69914http://www.autoitscript.com/forum/index.php?showtopic=69911
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now