.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

NetUserGetInfo/NetLocalGroupGetInfo returning error 1722

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :.NET Framework
I have the following code (VB.NET) which is designed to determine if a given account name refers to a local group or a user account. This will only be called for accounts/groups on a machine, not a domain. Module netapi Private Declare Function NetUserGetInfo Lib "Netapi32.dll" ( _ ByVal ServerName As String, _ ByVal UserName As String, _ ByVal level As Integer, _ ByRef BufPtr As IntPtr) As Integer Private Declare Function NetLocalGroupGetInfo Lib "Netapi32.dll" ( _ ByVal ServerName As String, _ ByVal GroupName As String, _ ByVal level As Integer, _ ByRef BufPtr As IntPtr) As Integer Declare Unicode Function NetApiBufferFree Lib "Netapi32.dll" _ (ByRef buffer As IntPtr) As Long Public Function GetPrincipalType(ByVal MachineName As String, ByVal AccountName As String) As String Dim bufPtr As IntPtr Dim lngReturn As Integer = NetUserGetInfo("\\" & MachineName, AccountName, 0, bufPtr) Console.WriteLine("NetUserGetInfo return value = " & lngReturn) Call NetApiBufferFree(bufPtr) bufPtr = IntPtr.Zero If lngReturn = 0 Then Return "User" End If lngReturn = NetLocalGroupGetInfo("\\" & MachineName, AccountName, 0, bufPtr) Console.WriteLine("NetLocalGroupGetInfo return value = " & lngReturn) Call NetApiBufferFree(bu

View Complete Post

More Related Resource Links

WebFaultException throwing a "not handled by user code" error and returning an HTTP 500 to the clien

I am trying to return a BadRequest and simple message when implentation throws an error in a WCF REST service, but the WebFaultExcption itself is throwing an exception and returning an HTTP 500 instead. Any ideas on why this might be happening? Here is a short code snippet: [WebDispatchFormatter] [WebHelp(Comment="Initiate an immediate or callback appoinment request")] [WebInvoke(UriTemplate = "InitiateContact", Method = Verbs.Post)] public string InitiateContact(AppointmentRqst rqst) {      string ret = string.Empty;      rqst.DeviceId = Helper.GetHttpAuthHdrDeviceId();      try      {          ret = impl.InitiateContact(rqst);      }      catch (Exception ex)      {          throw new WebFaultException<string>(ex.Message, HttpStatusCode.BadRequest);      }      return ret; }

Returning custom error messages with an UserNamePasswordValidator

Ok, my head hurts from banging it against the wall. I'm new to WCF, I have searched for a solution for days, please help a desperate fellow programmer if you can :-( I have a WCF service hosted in IIS, I implemented a UserNamePasswordValidator, and it seems impossible to find a way to return a custom error message to the client when the user is not allowed in, this blows my mind. I have searched everywhere, many are asking the same question since 2006 and so far I haven't found an answer that works. If you are thinking of replying that it is not secure to return a custom error message to an unauthenticated client, please save yourself some time and don't do it. There are multiple enterprise business scenarios that this is required. Just in our organization an account could be locked out, in which case the user must be directed to the IT department to get it unlocked, it could be that the credentials are correct but the user hasn't paid their fees in which case they must be directed to the appropriate department, or it could even be that the user tried to access the service during a time of the day in which the service is not available. From searching around, I have tried doing the things below in the Validate method, however the client always receives a MessageSecurityException, which contains none of the custom messages that were originally thrown, neither in the object,

Error calling WCF service that is returning list.".Debugging resource strings are unavailable ......

Ok.this is just making me frustrated... Here is step by step of what I am trying to do (& not able to) 1. I am calling WCF service hosted in a SharePoint 2010 site from a silverlight app in same domain (So no cross doman I guess). 2. I use Linq to Sharepoint for querying the DB. 3. I am having a list "machines" in Sharepoint 2010 that is having a lookup column from Other list called "part" 4. My WCF method GetAllMachines() works perfectly well when it skips the lookup column "partname" & returns List of type machineitem. 5. But problem occurs when I add machineitemobject.parts.partsname in my Linq to Sharepoint query . My service gives the error not found Async_ExceptionOccurred] Arguments: Debugging resource strings are unavailable." 6. Note that return type of my Method is List<machinesitem> 7. The point to note here is that I use SPMETAL tool to generate the LINQ class that maps the lists . So When I try to query the lookup column it tries to add List item of the type class & that is what causing the error. Is it because I am not using datacontract in my service (but it returns the strings & all private members of machines list e.g. name,title etc) Is it making the attribute Serialisable will solve the error ??? I am kind of lost in it ...Plss help!!   Thanks

Event Handler returning unexpected Error Code



I am trying to set up an Event Handler to log errors to a table.

So in my Control Flow pane I set an Execute SQL Task with a deliberate error as follows; -

Name; - Execute SQL Task with Deliberate Error

SQLStatement; - SELECT * FROM InvalidTable


Within the Event Handler tab I created a further Execute SQL Statement based on the Event handler OnError

Name : Log

Parameter Mapping
Variable Name System:ErrorCode
Direction Input
Parameter Name 0
Parameter Size 100

SQLStatement INSERT INTO dbo.CustomSSISLog  (ErrorCode) VALUES (?)

Error Output; -

SSIS package "ErrorLogTemplate.dtsx" starting.

Error: 0xC002F210 at Execute SQL Task with Deliberate Error, Execute SQL Task: Executing the query "SELECT * FROM InvalidTable" failed with the following error: "Invalid object name 'InvalidTable'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

Task failed: Execute SQL Task with Deliberate Error

Warning: 0x80019002 at ErrorLogTemplate: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of er

WCF service over https returning error


I am trying to deploy a wcf service. I have created a simple service, basically I have created a new wcf service and tried to deploy it however I get this error

The type 'WCF_Application.Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.


I am trying to deploy my service to a subdomain like https://services.mydomain.com/business


My config looks like this


      <service name="WCF_Application.Service1">
        <endpoint address="Business" binding="wsHttpBinding" contract="WCF_Application.IService1"
            <dns value="services.mydomain.com" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <add baseAddress="https://services.mydomain.com/" />

ActionFilter Returning To View On Handled Error (MVC2)


Hi People,

I have a action filter:

  public class ExceptionActionFilterAttribute : ActionFilterAttribute
        public void OnException(ExceptionContext filterContext)
            if ((filterContext.Exception != null) && (!filterContext.ExceptionHandled))
                var validationError = filterContext.Exception as EntityValidationError;

                if (validationError != null)
                    foreach (var error in validationError.ValidationErrors)
                        var errorMessage = error.PropertyName + " " + error.Message;
                      filterContext.Controller.ViewData.ModelState.AddModelError(error.PropertyName, errorMessage);

                    filterContext.ExceptionHandled = true;

                    // Would liek to return back to the view so it can display the changes made to modelstate above.
} } } }

Once the action filter handles the validation, instead of redirecting to another pages is it possible just to return the view associated with the action with the updated modelstate?

Basically this is to handle business validation exc

.Net FTP login failing, returning Error 530


I'm trying to log into an FTP server, retrieve a directory list and process the list.
The application is failing on the login with the following error message:

MESSAGE: The remote server returned an error: (530) Not logged in.

SOURCE: System


TARGETSITE: Void SyncRequestCallback(System.Object)

STACKTRACE:    at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)

   at System.Net.FtpWebRequest.RequestCallback(Object obj)

   at System.Net.CommandStream.Abort(Exception e)

   at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)

   at System.Net.FtpWebRequest.GetResponse()

I have been successful logging into the server (same cr

WCF service hosted in IIS 7 returning error "Security settings for this service require 'Anonymous'

Using the CalculatorService provided as a WCF sample from MSDN, I tried to host it as an application in IIS 7. The virtual folder in IIS is configured as Basic Authentication enabled and Anonymous Authentication disabled. I don't have any certificates setup. This is all hosted in a single machine setting. Each time I access the service through a browser, I'm getting the error "Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service".

Below is my web.config --

Can someone please provide some answer, I don't want to enable Anonymous authentication in IIS. I even set the 

aspNetCompatibilityEnabled = true.

<?xml version="1.0"?>


Error returning a data table

  1. public DataTable ExcelToDatatable_dt1  
  2.        &

Report Builder returning #Error value in empty fields and working with Date field


Hey guys,

I am trying to build a report using the date field from CRM and only wanting to return the date I am using this expression "=Fields!new_date.Value.ToShortDateString()" but when there is an empty fiel I get #Error. How do I solve this?

Also is there anyway to return the date field with the actual month showing instead of the numerical value? i.e. instead of 1/31/2010 Have it show January 31, 2010 (Doesn't have to be exactly in that format, but want the name value for the month.)

SPQuery returning error "One or more field types are not installed properly. Go to the list settings



SPQuery is not working properly, its throwing following exception.

"One or more field types are not installed properly. Go to the list settings page to delete these fields."

Please check the code snippet below:

SPSite spsite = new SPSite("siteurl");

SPWeb site = spsite.OpenWeb();

SPList list = site.Lists["listname"];

SPQuery query = new SPQuery();

query.Query = "<Where><Eq><FieldRef Name='ServiceLevel'/><Value Type='String'>345</Value></Eq></Where>";

SPListItemCollection items = list.GetItems(query);

Returning a DataSet From a Web Services: Step-by-Step

This Example Shows how to create a webservice which returns a DataSet and a Client Which displays the DataSet in a Grid.


This Example Shows how to create a webservice which returns a DataSet and a Client Which displays the DataSet in a Grid.

IsapiModule Error 500 Issue


I am about exhausted trying to figure out this error:

HTTP Error 500.0 - Internal Server Error

Description: The page cannot be displayed because an internal server error has occurred.

Error Code: 0x8007007b

Notification: ExecuteRequestHandler

Module: IsapiModule

Requested URL: http://localhost:80/ReportServer

Physical Path: c:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer

When I enable Failed Request Tracing Rules and view the log output I am supposing that the actual problem is in the 2nd call where there are 2 backslashes before the actual filename in the specified path:


CALL_ISAPI_EXTENSION DllName="C:\Windows\Microsoft.NET\Framework\v2.0.50727\\aspnet_isapi.dll"


Handling 404 page not found with Error page



      How do i handle 404 page not found?

Inserting personal error message in ValidationSummary



I am creating a web form that requires a lot of validation. I use many of the validation control in asp.net already like RequiredFieldValidator and CompareValidator. 

My Problem: after my custom validation for the value entered return an error message, and I pressed enter key when the field is empty, my custom error message is overlapped by my ValidationSummary. 

Setting my custom error to visible = false on button click also does not seem to work as it requires for me to enter the value first.

This made me think, is there a way to insert my custom validation inside the ValidationSummary as an error message like for other validation control?

Thanks in advance

Sys.Net.WebServiceFailedException: The server method '' failed with the following error:



Let's say we have 2 time consuming functions, aaa and aaa1 inside a aspx page.

        public static string aaa(int i)
            return i.ToString();

        public static string aaa1(int i)
            return i.ToString();



        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        <span id="displayspan"></span>
        <br />
        <input type="button" value=

Jscript error: Object does not support property or method


 Hi, i have little knowledge on javascript but i need to use this code get from somewhere for a jquery to work.

I face this "Jscript runtime error: Object does not support property or method" whenever im trying to run this page.

In my experience, im get this error msg 9 out of 10 times i use javascript in my system.

Im using Microsoft Visual web developer 2008, i wonder if this is related to my problem, i not sure there is anything i need to add as reference or update anything.

But anyway, in short, i just couldn't use javascript code when using this development tool because of this sort of error.

Anyway, it happen that last time i tried use the same type of jquery code in another project and it seems to work well without an error.

But now when im try to use it again in this recent project i created, it come out with this error and i have no idea how to solve it even look through google and this forum.

It doesn't really seems like its the code problem itself although im not sure, because any javascript code just couldn't work.

So below is my code that i need to use.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript" src=&quo
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend