Solved

How do I convert a string to a Hex?

Posted on 2006-11-21
7
708 Views
Last Modified: 2008-02-01
How do I convert the "disabled" to hex so I can & it with UF_ACCOUNTDISABLE))?  Thanks

int UF_ACCOUNTDISABLE = 0x2;
string disabled = deChild.Properties["userAccountControl"].Value.ToString();

          if ((disabled.ToString("X2")) & (UF_ACCOUNTDISABLE))
0
Comment
Question by:lapucca
  • 4
  • 3
7 Comments
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17990830
what type is the value in
deChild.Properties["userAccountControl"].Value ?
0
 

Author Comment

by:lapucca
ID: 17990923
0
 

Author Comment

by:lapucca
ID: 17990939
I'm trying to determin if the account is disabled.  Would that make the end result 1 or 0?  Thanks.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:lapucca
ID: 17991023
Following the example on http://msdn2.microsoft.com/en-us/library/ms180916.aspx

My following code is getting me an error.  How can I correct this?  Thanks.

Error      2      Cannot implicitly convert type 'int' to 'bool'      C:\Projects\UnityAdmin\Main.cs      821


int disabled = (int)deChild.Properties["userAccountControl"].Value;
if ((disabled) & (UF_ACCOUNTDISABLE))//if disable then use the disabled icon
    newLvNode = NodeDetail.Items.Add
        (new ListViewItem(new string[] { commonName, os, osVersion }, 2));
else
    newLvNode = NodeDetail.Items.Add
        (new ListViewItem(new string[] { commonName, os, osVersion }, 11));
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17991107
I believe that the if statement you want should be this...

int UF_ACCOUNTDISABLE = 0x2;
bool disabled = (deChild.Properties["userAccountControl"].Value & UF_ACCOUNTDISABLE == UF_ACCOUNTDISABLE);

          if (disabled)
          {
          }
0
 
LVL 7

Accepted Solution

by:
Mohamed Zedan earned 500 total points
ID: 17991122
I believe that the if statement you want should be this...


int UF_ACCOUNTDISABLE = 0x2;
bool disabled = ((deChild.Properties["userAccountControl"].Value & UF_ACCOUNTDISABLE) == UF_ACCOUNTDISABLE);
//forgot these    ^                                                                                                       ^
          if (disabled)
          {
          }
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17991199
If it gives you an error please send it here... and try this next

int UF_ACCOUNTDISABLE = 0x2;
bool disabled = (((int)deChild.Properties["userAccountControl"].Value & UF_ACCOUNTDISABLE) == UF_ACCOUNTDISABLE);

          if (disabled)
          {
          }
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now