|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
Iterate through UserAccountControl flag
I am working with Active Directory to manage user accounts. In Active Directory, there's an attribute called UserAccountControl which has a cumulative set of flags that displays the user's account status (locked out, disabled, no password required, etc). Take a look at the codes here: http://support.microsoft.com/defaul...b;en-us;Q305144
What I want to do is write a UDF that will parse the current account's UserAccountControl attribute and return a list of each flag that is set. For example, if a user's UserAccountControl attribute is 514, the list would contain "Normal Account, Disabled". Another example would be is a user's UserAccountControl attribute was 8389136, the list would be "Password Expired, Normal Account, Locked Out". I'm just not sure how I should process the attribute to extract the flags... |
|
#2
|
||||
|
||||
|
I got it. In case anyone here needs it:
<cffunction name="GetAccountFlags" output="false"> <cfargument name="UserAccountControl" required="yes"> <cfset flag=16777216> <cfset accountFlags=ArrayNew(1)> <cfset i=1> <cfloop condition="#flag# greater than or equal to 1"> <cfif UserAccountControl greater than or equal to flag> <cfset accountFlags[i]=flag> <cfset UserAccountControl=UserAccountControl-flag> <cfset i=i+1> </cfif> <cfset flag=flag/2> </cfloop> <cfset flagList=ArrayToList(accountFlags)> <cfreturn flagList> </cffunction> |
|
#3
|
|||
|
|||
|
Just a note that you should be scoping your function-local variables with the VAR keyword, like this:
<cfset var flag = 2029420384 /> This creates a function-local variable instead of creating it in the variables scope where it is accessible outside the function (breaks encapsulation). Var scoped variables have to appear at the top of the function right after the arguments.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#4
|
||||
|
||||
|
Cool, thanx!
By the way, I noticed you wrote your tag in XHTML format ' />'. I can do this in ColdFusion? I write everything in XHTML, and doing that to my CFML will make my code much cleaner. |
|
#5
|
|||
|
|||
|
Yep, you can write CFML that's compliant with XHTML.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Iterate through UserAccountControl flag |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|