reading userAccountControl flags

  • Thread starter Thread starter Morten
  • Start date Start date
M

Morten

Hi!

I'm trying to determine if an AD user has the "Password never expires" flag
set. I've only been able to find some vb script examples that show how to do
this but I haven't been able to translate this to C#.

I've tried this:

if ((dirEntry.Properties["userAccountControl"].Value &&
UF_DONT_EXPIRE_PASSWD) == 0)



but that results in an error: Operator '&&' cannot be applied to operands of
type 'object' and 'int'

Can someone help with this?

Thanks in advance

Morten
 
Value returns an object, so you need to cast to an int first.
(((int)dirEntry.Properties["userAccountControl"].Value && ...

Willy.

| Hi!
|
| I'm trying to determine if an AD user has the "Password never expires"
flag
| set. I've only been able to find some vb script examples that show how to
do
| this but I haven't been able to translate this to C#.
|
| I've tried this:
|
| if ((dirEntry.Properties["userAccountControl"].Value &&
| UF_DONT_EXPIRE_PASSWD) == 0)
|
|
|
| but that results in an error: Operator '&&' cannot be applied to operands
of
| type 'object' and 'int'
|
| Can someone help with this?
|
| Thanks in advance
|
| Morten
|
|
 
That gives the error:

Operator '&&' cannot be applied to operands of type 'int' and 'int'

Morten
 
True, both should be uint's, the userAccountControl flags are unsined int's
anyway.


Willy.

| That gives the error:
|
| Operator '&&' cannot be applied to operands of type 'int' and 'int'
|
| Morten
|
| | > Value returns an object, so you need to cast to an int first.
| > (((int)dirEntry.Properties["userAccountControl"].Value && ...
| >
| > Willy.
| >
| > | > | Hi!
| > |
| > | I'm trying to determine if an AD user has the "Password never expires"
| > flag
| > | set. I've only been able to find some vb script examples that show how
| > to
| > do
| > | this but I haven't been able to translate this to C#.
| > |
| > | I've tried this:
| > |
| > | if ((dirEntry.Properties["userAccountControl"].Value &&
| > | UF_DONT_EXPIRE_PASSWD) == 0)
| > |
| > |
| > |
| > | but that results in an error: Operator '&&' cannot be applied to
| > operands
| > of
| > | type 'object' and 'int'
| > |
| > | Can someone help with this?
| > |
| > | Thanks in advance
| > |
| > | Morten
| > |
| > |
| >
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top