08/11/06

Permalink 08:18:49 pm, Categories: Microsoft.NET, Windows Services, 117 words   English (US)

How do I get the Username in Windows Services?

SYMPTOMS
If a Windows Service running under Local System Account, System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString() returns NT AUTHOURITY\SYSTEM

You want to get who logged on to the machine?

CAUSE
Windows Service is running under Local System Account. Current user credentials will be NT AUTHOURITY\SYSTEM. You have to query WMI to get current users logged on to the machine.

WORKAROUND
To work around this problem, use following code.

ManagementObjectSearcher searcher = new
ManagementObjectSearcher("SELECT UserName, Name FROMWin32_ComputerSystem");

foreach (ManagementObject mo in searcher.Get()) {
if (mo["UserName"] != null) {
vUserName = mo["UserName"].ToString();
}
if (mo["Name"] != null) {
strComputer = mo["Name"].ToString();
}
}
searcher.Dispose();
searcher = null;

Email me if you want VB.NET or C++.NET Code

Permalink 08:16:32 pm, Categories: Microsoft.NET, Web Services, 255 words   English (US)

How to call a web service using Javascript?

For example:
You want to get a client name from the client list. "GetClientName" function exposed through web service name called "Service1.asmx" and the function takes "Client Code" as a passing variable.

Copy the WebService behavior (webservice.htc file) into the Web project folder.

You can download webservice.htc file at this link: http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/internet/behaviors/library/webservice/default.asp

Copy this javscript code and name it webservice.js and copy into the Web project folder.

var iCallID1;

function onBlur()
{
Get_ClientName();
}

function onEnter()
{
var kCode=event.keyCode;
if(kCode==13)
{
Get_ClientName();
}
}

function onWSresult()
{
if (event.result.error)
{
var xfaultcode = event.result.errorDetail.code;
var xfaultstring = event.result.errorDetail.string;
var xfaultsoap = event.result.errorDetail.raw;

alert("Error: " + xfaultcode + "|" + xfaultstring + "|" + xfaultsoap + "|");
}
else
{

if (iCallID1==event.result.id) {
document.all("ClientName").innerHTML = event.result.value;
}
}
}

function Get_ClientName() {
if (document.all("ClientCode").value != "") {
service.useService("http://www.charora.com/WebServices/Service1.asmx?WSDL","MyWebService");
iCallID1 = service.MyWebService.callService("GetClientName", document.all("ClientCode").value);
}
else {
alert ("Please enter client code ... ");
}
}

Create test.htm and include webservice.js in the test.htm

add a DIV tag and with following attributes

id="service"
style="behavior:url(webservice.htc)"
onresult="onWSresult();"

add input tag and with following attributes

type="text"
name="ClientCode"
Text=""
onblur="onBlur();"
onkeypress="onEnter();"

add another input tag and with following attributes

type="text"
name="ClientName"
Text=""

Finally, browse the test.htm file and enter client code and hit enter.

You will get the client name.

Permalink 08:01:48 pm, Categories: Interesting Links, 4 words   English (US)

http://www.callcentermovie.com/

Interesting call center movie ...

Permalink 07:59:41 pm, Categories: Interesting Links, 2 words   English (US)

Interviewing at Microsoft

Interesting Link

Permalink 03:30:23 pm, Categories: MS SHAREPOINT, 228 words   English (US)

Unable to search in SharePoint Portal Server 2003

SYMPTOMS
Whatever you try to search for in SharePoint Portal Server 2003, You do not get any results, you may receive the following error message in the error log if you go to "Site Settings->Configure search and indexing->View errors and warnings on:" and click on "portal content" or "non portal content"

The address could not be found, (0x80041209 - Cannot Connect to the server. Please make sure the site is accessible. )

The address could not be found, (0x80041206 - A server error occurred. Check that the server is available. )

CAUSE
full-text search is not configured properly

WORKAROUND
To work around this problem, follow these steps.

1. Login as SharePoint Administrator Group Account
2. Go to SharePoint Central Administration
3. Click on Windows SharePoint Services from left navigation bar.
4. Click on Configure full-text search and uncheck and check "Enable full-text search and index component" under Search Settings and type "SharePoint Administrator Group Account" User ID and Password if prompted.
4. Open Enterprise Manager in SQL Server 2000 or SQL Server Management Studio in SQL Server 2005.
5. Go to the database server then open the "SITE" database
6. You should see Full-Text Catalog node, right click on the catalog icon to start full population. If you receive an error message then run this stored procedure. Make sure you are running the stored procedute in the "Site" database.

EXEC sp_fulltext_database 'enable'
GO

This should fix the problem

:: Next Page >>

Blog - All

This blog is to publish all articles.

This allows you to keep track of all the technical posted on this system.

| Next >

July 2010
Mon Tue Wed Thu Fri Sat Sun
<<  <   >  >>
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Search

Archives

Misc

Syndicate this blog XML

What is RSS?

powered by
b2evolution