Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

Anzy

@Anzy
About
Posts
30
Topics
16
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Memory Handling Check
    A Anzy

    Hi.. I'm very new to C++ and have just written 2 methods that are pretty unstable (ie. same input may or may not run correctly). My gut feeling tells me it's because of my poor memory and string management. Could someone kindly review the code and let me know if there's any obvious error? I would seriously very appreciate it. Method 1 ============

    char* _LoggedInUserID;
    char* _LoggedInUserName;
    DWORD CALLBACK streamDisclaimer(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
    {
    DWORD read;
    CRtfStream *st = reinterpret_cast(dwCookie);
    const int MAX_USER_TAG = 10;

    char\* userTag = (char\*) malloc(strlen("")+1);
    strncpy(userTag, "", strlen(""));
    userTag\[strlen("")\] = '\\0';
    
    size\_t displayLen = strlen(\_DlgLoggedInUserID);
    if(\_DlgLoggedInUserName != NULL) displayLen += strlen(\_DlgLoggedInUserName) + 3;  	char\* displayStr = (char\*) malloc(displayLen+1);
    
    if(\_DlgLoggedInUserName != NULL){
    	sprintf(displayStr, "%s (%s)", \_DlgLoggedInUserName, \_DlgLoggedInUserID);
    }else{
    	sprintf(displayStr, "%s", \_DlgLoggedInUserID);
    }
    displayStr\[displayLen\] = '\\0';
    
    LPBYTE tmpBuff = new BYTE\[cb + (displayLen\*MAX\_USER\_TAG)\];
    
    ReadFile(st->fileDisclaimer.get(), tmpBuff, cb, &read, NULL);
    string tmBuffStr = (char\*) tmpBuff;
    size\_t iPos      = tmBuffStr.find(string(userTag), 0);
    
    if(iPos != tmBuffStr.npos){
    	int cnt = 0;
    	while(iPos != tmBuffStr.npos && cnt < MAX\_USER\_TAG){
    		tmBuffStr = tmBuffStr.erase(iPos, strlen(userTag));
    		tmBuffStr.insert(iPos, displayStr);
    		iPos = tmBuffStr.find(string(userTag), 0);
    		cnt++;
    	}
    	int newLength = read - (strlen(userTag)\*cnt) + (displayLen\*cnt);
    	strncpy((char\*)pbBuff, tmBuffStr.c\_str(), newLength);
    	pbBuff\[newLength\] = '\\0';
    	\*pcb = newLength;
    }else{
    	strncpy((char\*)pbBuff, (char\*)tmpBuff, read);
    	\*pcb = read;
    }
    
    // clean up
    delete \[\] userTag;
    delete \[\] displayStr;
    
    userTag    = NULL;
    displayStr = NULL;
    tmpBuff    = NULL;
    
    return 0;
    

    }

    Method 2 =============

    char* _DlgLoggedInUserID;
    char* _DlgLoggedInUserName;

    void CGina::setLoggedInUserID(PWSTR pszUserName){

    // free memory dynamically allocated
    delete \[\] \_LoggedInUserID;  
    delete \[\] \_LoggedInUserName;
    
    // deallocate memory that's not used
    \_LoggedInUserID   = NULL;
    \_LoggedInUserName = NULL;
    
    if(pszUserName != NULL)
    {
    	int nstrlen = WideCharToMultiByte(CP\_ACP, 0, pszUserName, -1, NULL, 0, NULL, NULL);
    	PSTR UserNameStr = (PSTR)HeapAlloc(GetProcessHeap(),0,ns
    
    C / C++ / MFC c++ performance help question

  • Validating and redirecting using a class ...
    A Anzy

    Is your CheckLogin just a class or a website (ie. is it a .aspx.cs file?) From the exception you are getting it seems CheckLogin is not a website and hence it explains why you cannot use Page.Response.Redirect(). I've never tried this before and not sure if this is the best option, but you might want to consider using something like this: System.Web.HttpResponse x = new HttpResponse(); x.Redirect("");

    ASP.NET design help

  • SQL - write file
    A Anzy

    Hi all, I'm currently trying to write a few lines into a csv file from a sql package. One thing I have to make sure is that the csv file doesn't end with a blank line. That is, I have to delete all new line and return feed from the end of the file. I've tried: fileOut := utl_file.fopen('xxx', 'yyy', 'W', 32760); utl_file.put_line(fileout, 'line 1' || Chr(13)); utl_file.put(fileout, 'line 2'); utl_file.fclose(fileOut); But when I open the csv file created, there's always a blank line at the end of the file. It seems like a blank line is always being appended to the end of the file automatically on file close. Is this true? And are there any ways of avoiding this through sql? Thanks

    Database database question

  • Assign string value in TextBox only display before space value
    A Anzy

    You might want to try this: I have a feeling at the moment your html source is showing and hence it doesn't know "Bed" also belong to the value attribute so your goal is to sure the html source display something like:

    ASP.NET help

  • 401.1 Unauthorized - IIS 6 &amp; Integrated Window Authentication Only
    A Anzy

    This is what I've found: Cause of problem: Kerberos breaks when a customised application pool is created using a customised identity. For my case I used a domain user as the pool identity. Resolution 1. Avoid Kerberos and use NTLM authentication instead. To do this: cd c:\intetpub\adminscripts cscript adsutil.vbs set w3svc/??/NTAuthenticationProviders "NTLM" NB: where ?? is your website's identity id (you can get this id from the iis manager -> Web Sites -> Identifier column 2. Fix Kerberos by setting up appropriate Service Principal Name (SPN). setspn -A HTTP/servername domain\account setspn -A HTTP/server_fully_qualified_domain_name domain\account Servername and server_fully_qualified_domain_name are retrievable from DNS and are both referring to the server/machine that your service is running on. domain\account is referring to the identity you use for you r customised application pool. At the moment I'm still having trouble setting up the SPN correctly. However, hope my finding will help someone one day. Thanks, Anzy

    ASP.NET help windows-admin security xml question

  • 401.1 Unauthorized - IIS 6 &amp; Integrated Window Authentication Only
    A Anzy

    Hi All, I have an application running on IIS 6 and in a customised application pool called MyAppPool. MyAppPool is running as a domain user identity. The virtual directory has Integrated Window Authentication enabled only. I've also set the following: - Added domain user to IIS_WPG - Added domain user to Log on as a batch job - Added domain user to Log on as a service Now the problem I'm getting is everytime when I try to access the application I get prompted for my credential. After entering the valid credential 3 times I get the Unauthorized Access error. I've been googling for 2 days and found a possible solution is to add the line: NTAuthenticationProviders="Negotiate,NTLM" to IIS Metabase.xml However, after restarting iis the issue remains. Could someone please help? Thank you

    ASP.NET help windows-admin security xml question

  • DirectorySearcher cannot Sort
    A Anzy

    Hi all, I'm having a problem sorting my results from DirectorySearcher. Here's the code:

    DirectorySearcher searcher = new DirectorySearcher(new DirectoryEntry("xxx"));
    searcher.PropertiesToLoad.AddRange(new string[]{"f1","f2"});
    searcher.Filter = "(f2=value)";
    searcher.Sort = new SortOption("f1",SortDirection.Ascending);
    SearchResultCollection res = searcher.FindAll(); <-- throw exception

    Up to the last line an exception will be thrown stating: "The value for the property Sort could not be set.". Could someone please give a hand on this? I'm using VS .NET v1.1.4, would it be because this version doesn't support Sort for DirectorySearcher? Thanks all, Anzy

    ASP.NET csharp visual-studio algorithms help question

  • Assembly Permission to Network Files
    A Anzy

    Hi all, I've asked about this problem before but now the problem is abit different. I have a strong name assembly that is able to access/read files that are on local machine but NOT on any network machines/servers (using UNC). I've used Caspol.exe to check its permission and got:

    < PermissionSet class="System.Secuirty.PermissionSet" Unrestricted="true" ...>
    <IPermission class="System.Security.Permissions.ZoneIdentityPermission, mscorlib, ..." Zone="MyComputer"/>
    </PermissionSet>

    Does anyone have any idea as to what could be causing this? :doh: Thank you, Anzy

    ASP.NET sysadmin security help question

  • Assembly & Security
    A Anzy

    Hi, Really thank you for your patience. But I've actually tried this method before but am getting an error that doesn't make sense. This is exactly what happened: Say the DLL has the name CONTROLLib: 1. Created keyfile.snk & moved it to C:\ 2. Typed in the [assembly:...] codes and changed the 'name.snk' to 'keyfile.snk' 3. Tried compiling and it threw an error: "Assembly generation failed -- Referenced assembly 'Interop.CONTROLLib does not have a strong name" But I thought the whole point of this is to make CONTROLLib.dll a strong name? Am I missing something trivial here?

    ASP.NET question sysadmin security help

  • Broken images when using web.config
    A Anzy

    Did you include images/logo.gif in the project? As far as I know if it is, authorisation should not affect this at all.

    ASP.NET security help question workspace

  • Validators
    A Anzy

    Oops, sorry to confuse you. Development Box - a server/machine used for development and testing purposes. Production Box - a server/machine hosting live websites. Both 'supposedly' have the same visual studio .net and iis configuration.

    ASP.NET question

  • Assembly & Security
    A Anzy

    Hi, I'm not quite sure what you mean by 'R and D' but I did give the administrative tools a few attempts before posting my question here. In .NET Configuration tool, I've tried adding the assembly but failed because it's 'Not a strong name'. Searched online and tried a few methods but still couldn't make my assembly 'a strong name' - currently still trying... In .Net Wizards, I've use 'Trust an Assembly' function to give my assembly 'Full Trust'. But the problem is still there. :confused:

    ASP.NET question sysadmin security help

  • Assembly & Security
    A Anzy

    Unfortunately that's what makes things abit harder. The exception I'm getting is: "Exception from HRESULT: 0x80040A08." I've searched online but hasn't found any clues as what this exception stands for. And from the tests I've specified in previous post, it seems security is the most likely explanation?

    ASP.NET question sysadmin security help

  • Validators
    A Anzy

    I've solved the problem by setting all validators' 'EnableClientScript' to false. Apparently the production server does not support client-side validation/scripting for some reason, so the only option left is to use server-side without the need to manually write the validation code. HTH Anzy

    ASP.NET question

  • Validators
    A Anzy

    Hi all, I have some RequiredFieldValidators and CompareValidators that are working fine on development box but not working at all on production. Does anyone have a clue why this is the case? Thank you, Anzy

    ASP.NET question

  • Assembly & Security
    A Anzy

    Hi all, I'm having a security problem with an assembly/dll that is not strong named. Here are the detail: Say I have a file {x} ... - If I use my dll to access {x} locally everthing runs fine. - If I use my dll to access {x} over the network (using UNC) it throws exception. - If I use the System.IO.File object to access {x} over the network (using UNC) everything runs fine. My conclusion is that my dll doesnt have enough permission to access network files/directories. My questions is, how do I change the permission level of a dll that's not strong named or registered? Thanks

    ASP.NET question sysadmin security help

  • Finding a file over network &gt;&lt;
    A Anzy

    I've tried putting \\xxx into the HOSTS file on Server B, but it still cannot find file. I think it's more of a security problem than anything. I'm having similar problem with defaultCredentials too. As my site is impersonating the logged on users ( using Integrated Window Auth, and <identity impersonate="true" /> ), Server A is able to use the defualtCredentials to gain access to certain urls while Server B isn't. Thanks, Anzy

    ASP.NET help sysadmin xml

  • Finding a file over network &gt;&lt;
    A Anzy

    Hi, Really really need someone's help on this one. I have 2 servers, A and B. On both servers, I called the following code: File.Exists(@"\\xxx\yyy\file.xml"); Server A returns: true Server B returns: false The file indeed EXISTS. Could ANYONE tell me why server B cannot see the file and how could I possibly fix this problem. Really really thank you if you could solve this for me. Anzy

    ASP.NET help sysadmin xml

  • Table Control
    A Anzy

    Hi all, Currently I have a Table object that's being populated on Page_Load(). ----------------------------------------------------------------------- protected System.Web.UI.WebControls.Table Table_Menu; private void Page_Load(object sender, System.EventArgs e) { populate_table(Table_Menu); } ------------------------------------------------------------------------- This table object contains controls like LinkButtons or other more Table objects (nested tables). But this results in 2 problems: Problem 1. States of the nested table properties (eg, visible, enable) cannot be maintained, since the table gets regenerated on each page load. Problem 2. Generating the table is expensive. So I really need a way that would allow me to generate the table only once or just less. If anyone cld help it'd be really appreciated. Thanks.

    ASP.NET help css design

  • How to use DirectorySearcher's Sort ?
    A Anzy

    Hello, Has anyone successfully sorted their Directory results using DirectorySearcher's sort method? I've tried both: Method 1: searcher.Sort = new SortOption("xxx",SortDirection.Ascending); and Method 2: searcher.Sort.PropertyName = "xxx"; searcher.Sort.Direction = SortDirection.Ascending; Where "xxx" is one of the DirectoryEntry's children's property names. Both giving me the error: "The value for the property Sort could not be set." Could anyone help plzzz!? Thxs..

    ASP.NET help tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups