I'm building a little toolkit wrapped into an HTA for use in a helpdesk. One of the tasks I'd like to have included is the ability to quickly pull info about a domain user. Now, normally, I would just use something like Net User USERNAME /domain and get a quick little blurb. Works great.
However, I can't seem to find a way to integrate that into the script for the toolkit. I could probably use cscript and just dump the output, but then I would have a heck of a time getting it formatted into anything interactive (the whole point of the HTA).
I'd really like to use something like ADSI. I can pretty easily get members of a given group, or the primary group of a given user, but I can't seem to find a way to list all the memberships of a username on the domain.
Note, that pulling all the groups and users, then comparing them is not an option. This is for a domain with hundreds of thousands of users.
I promise I have googled for days on this thing. Dug around in the documentation etc, but nothing really seems to do what I need.
This is similar to your comment about running CSCRIPT and dumping the output.
You can consider using the WScript.Shell object instead, specifically, the Exec method to run a command from within your HTA and make use of stdout.readAll to suck the output.
The following example shows how you would do this to capture the output of IPCONFIG into your HTA:
<html>
<head>
<hta:application icon="http://www.stackoverflow.com/favicon.ico"/>
<title>WScript.Shell Example</title>
<script language="VBScript">
Sub RunCommand
Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
Dim wshExec
Set wshExec = wshShell.Exec("IPCONFIG")
textAreaResult.value = wshExec.stdout.readall
End Sub
</script>
</head>
<body onload="RunCommand">
<textarea id="textAreaResult" style="width:100%;height:300"/>
</textarea>
</body>
</html>
Related
Good evening, I'm working with Google Custom Search Engine: https://cse.google.it/cse/ and I need to add, only for some URLs (in total 10 URLs) a parameter at the end of each search results URL. For example: if the domain is www.dominio-test.com then the URL to show is www.dominio-test.com/123456 the CSE searches on the web without restriction.
The code I use is the following:
<script async src = "https://cse.google.com/cse.js cx=014431187084467459449:v2cmjgvgjr0"> </script>
<div class = "gcse-search"> </div>
I thought of proceeding with reading the DOM with getElementsByClassName (), extracting the content and adding it to a variable, at this point add the if / else / replace controls and output again.
But I don't know how to proceed, can you please support me?
Thanks and good job
Search Element callbacks might work for you: https://developers.google.com/custom-search/docs/element#callbacks
I'm subscribed to the free Bing Search API on the Windows Azure website. What I want to do is add a panel to my website that uses purely client-side code (javascript) to query the Bing Search Api for News results, which I want to be sorted by relevance.
In order to get this to work I found this interesting article which talks about how to store your authentication information in YQL (Yahoo Query Language) and use it as a proxy to query the Bing Search API at: http://derek.io/blog/2010/how-to-secure-oauth-in-javascript/
So, here is what I did:
1) Develop a YQL Open Data Table which contains my Bing Key and a query parameter. Here is the XML Code:
<?xml version="1.0" encoding="UTF-8" ?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<sampleQuery>
select * from {table} where query="washington"
</sampleQuery>
</meta>
<bindings>
<!-- SearchResponse.News.RelatedSearches.NewsRelatedSearch -->
<select produces="json">
<urls><url>https://a889dc2f-d0d4-4d16-9f4e-401c750deb04:IFU5P1aw5HAFJsMgOoxSyAAQyAh+m5asVkEq3GG9xIU#api.datamarket.azure.com/Bing/Search/v1/Composite?Sources=%27news%27</url></urls>
<inputs>
<key id="Query" default="'new york bonds'+NewsCategory='rt_Business'" paramType="query" />
</inputs>
</select>
</bindings>
</table>
See where I put the ConsumerID and AccountKey? It's at the very beginning of the URL (separated by a colon).
2) Save this data table in YQL's hosted storage. I get back execute, select, and update Storage Addresses. This allows me to hide my Auth information, while eliminating the need for a server-side proxy.
3) Use the Execute Storage Key given by: store://6sVu1WUPgFrgFcOv1bH81U to make a YQL query from, say, the YQL Console. Let's use the following query:
use "store://6sVu1WUPgFrgFcOv1bH81U" as T;
select * from T where Query="'Texas bonds'&NewsCategory='rt_Business'";
Uh oh... we hit the first error. The YQL Console eats it and spits out "Invalid JSON Document." Okay, so I think the console doesn't know how to parse this query.
Fine, then let's just use the REST URL to perform the query. The URL is:
https://query.yahooapis.com/v1/public/yql?q=use%20%22store%3A%2F%2F6sVu1WUPgFrgFcOv1bH81U%22%20as%20T%3B%20select%20*%20from%20T%20where%20Query%3D%22%27Texas%20bonds%27%26NewsCategory%3D%27rt_Business%27%22%3B&format=json&diagnostics=true
Great! But something interesting is happening here. The diagnostics in the resulting JSON string say:
"Failed to read from storage... not a valid storage address."
I could care less, as long as I get a good JSON string I don't care. But here is where the problem occurs. Try using the resulting REST URL for this query:
use "store://6sVu1WUPgFrgFcOv1bH81U" as T;
select * from T where Query="'Texas bonds'&NewsCategory='rt_Business'&NewsSortBy='Relevance'";
The result is an empty string (with the same storage url error).
WHY?! This is the exact same query, but it just sorts the News Results by relevance instead of date.
Does anyone know what the heck is going on here?
Thanks in advance for your time, it is MUCH appreciated.
P.S. I've tried putting in other key id's to make the XML code better looking but it would always screw up the query. Please let me know if you can get this working I will love you forever.
Do you think it might have to be done using OAuth?
I have a php script (ini.php), that open in an iframe inside of "main.php":
<iframe src='ini.php' style='width:650px;' frameborder='0' id="IDMain" allowtransparency="YES" scrolling="NO"></iframe>
The SQL does not retrieve the data in "ini.php".
But if I incorporate the code of "ini.php" in "main.php", without using an iframe, the query retrieves all the information.
I must have an iframe in order to change all the different scripts in the same iframe.
Any help here?
Thanks
In addition more information:
The main.php is in session after logged. Previously I had the whole frame repeated in each script, and everything was ok.main.php, ini.php, and so on. Each script with header, left, right, main and footer. To make it faster and easier I decide to make the main script called main.php, that with an included script called config.inc.php that has several functions, also connects to data base, to retrieve some data to the header, left , right and footer sides of the main area (iframe) where the others different scripts, just to opens inside of a iframe, maintaining the information around. Each script, (like ini.php), that runs in the iframe also include the config.inc.php file, to connect as well to database. But does not retrieve any information
The connection to database in config script is:
<$connect=mysql_connect ("localhost","database","password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("database", $connect) or die ("'I cannot connect to the database "); >
The query in ini,php (and others) is:
`
if ($id) {
$id_session=$_SESSION['id_session'];
$namesession=$_SESSION['name_session'];
$sql="select * from data where id='$id_sessino' limit 1 ";
$result=mysql_db_query("database",$sql);
$regist=mysql_fetch_array($result);
$id=$regist["id"];
$id_session=$regist["id"];
$namesession=$regist["name_session"];
$country=$regist["country"];
And soo on…
}
`
I hope with is information it makes it clear what do I mean. Thank you
Check PHP help for mysql_db_query. Since you are not giving it any open db link, it tries to do some default magic, which likely fails, because, as I mentioned in the comment, the two scripts (in parent window and inside the iframe) are run separately and have no idea about each other *unless you are doing some synchronizing, that isn't shown in the code snippets. That means that the iframe script doesn't know anything about the connection you've opened in the parent page, and fails. Check your logs, you should see some E_WARNING complaints (if you are logging this level).
Also, as the documentation says, you might be better off with MySQLi or PDO_MySQL extensions. But the principle will remain the same - the script in questoin has to have an open connection to the database (and I'm not sure whether you can easily and safely transfer an open from one script to the other one, so you'll likely have to do it all in the iframe script).
Try two things, first I would change the MySQL_fetch_array part to
While($regist = mysql_fetch_array($result))
{
//Code goes here
}
Secondly try referring to the array vales as numbers rather than names, so regist['id'] would become regist[0]. They will be in the order the are in the database.
Also since you select your database when creating connection why not just use mysql_query("QUERY HERE"); Rather than mysql_db_query
I would like to add <meta name="description" content="....."/> to the html pages for indexing server to pick it up.
I got the property "description" in indexing server, but I don't know how to write the query to select it.
select description from scope() where ......, but it is not working, error message is "DESCRIPTION IS NOT DEFINED".
I need your help.
Thanks
Tony
P.S. I am using WINDOW 2003 R2
after adding the FriendlyNamesDefinitionFile.txt to C:\WINDOWS\system32 and update the DefaultColumnFile value under ContentIndexCommon key, it is working now. But still cannot find any documentation about it. My stations is Window 2003 Server(64 bit). Grant the correct permission to the folder where the files are.
Rather than searching for 'description', you might want to try searching for 'characterization' instead. This worked for me -- with the bizarre caveat that the order of the attribute values on your <meta> tags has to be name, then content (I tried the other way around and the search stopped working).
I agree that the lack of documentation on the Windows Indexing Server is quite frustrating.
I have a single Classic ASP page that I wish to display a search form and the associated results.
When a user first comes to this page, I want to display a search form and the 10 latest properties. If a user decides to use the search form to retrieve more relevant properties, then i want the default 10 latest properties to be replaced with the users' paged search results.
I was wondering if this is possible/practical within the confines of one page and if so, does anyone have any hints on how i could best achieve this?
This is my preliminary code for such a page;
http://gist.github.com/188770
Once again, i'm currently having to patch an existing ASP site until I can redevelop it in something more modern like PHP.
Thank you for any help offered.
Neil.
It's certainly very possible and practical. Typically the solution is to postback to yourself and have code in the page that detects if you arrived there from a post or a get. Get meant show the 10 latest properties, post means you do a search and show the results.
if (Request.ServerVariables("REQUEST_METHOD") = "POST") then
' arrived via post, get form values and do search
else
' arrived via get, show last 10 results
end if
You probably want to display what the user searched for in the form when you display the result:
<label>Street: <input type="text" name="searchStreet" value="<%=Server.HtmlEncode(Request("searchStreet") & "") %>" /></label>
Adding a empty string is for casting to string to not give an error when the key wasn't found, eg. on first visit.
If you want to you can make the loop prettier:
do until myRecordSet.EOF
%>
<div class='result'>")
<dl><%=myRecordSet("ContentTitle")%><dl>
<dt><%=myRecordSet("ContentStreet")%><dt>
<dt><%=myRecordSet("ContentTown")%><dt>
<dt><%=myRecordSet("ContentPostcode")%><dt>
</div><%
myRecordSet.MoveNext
loop
You probably want to Server.HtmlEncode there as well...
(ps ASP is actually one year younger than PHP... if you want something modern you might want to look at python, ruby or asp.net mvc before PHP, as it's easier to write bad code in PHP than in any of those. ds)