Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8708831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:13:41+00:00 2026-06-13T04:13:41+00:00

I am trying to decode the logonHours attribute from Active Directory so that it

  • 0

I am trying to decode the logonHours attribute from Active Directory so that it displays in my Java application properly. When I look in the attribute editor, it looks like this:

logonHours 03 00 00 00 F0 FF 1F F0 FF 1F F0 FF 1F F0 FF 1F F0 FF 1F 00 FF

This is precisely 21 bytes long, which is what I expect (each day is encoded in 3 bytes, for a total of 24 bits per day). This is meant to match the display under logonHours I have. However, my encoding is as follows (bit-strings for each day)

Sun:     00000000 (00) 00000000 (00) 00000000 (00)
Mon-Fri: 00001111 (0F) 11111111 (FF) 11111000 (F8)
Sat:     00000000 (00) 11111111 (FF) 11000000 (C0)

This makes me think that there is some encoding happening between the logonHours attribute and the display. I’ve looked at the Perl code and the VBScript – converting either of these in Java does a straight conversion, which does not match up with reality.

Does anyone has Java, C#.NET or other pseudo-code for decoding the logonHours attribute properly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:13:42+00:00Added an answer on June 13, 2026 at 4:13 am

    I hate it when I figure these things out ten minutes later after I’ve thrown up my hands and asked for help. The key is in this page: Active Directory Permitted Logon Times with C# .Net 3.5 using System.DirectoryServices.AccountManagement – specifically, the ordering of the bits and the fact that the array starts with an off-by-1 issue. Here is the code for Java I came up with:

    private String[] decodeLogonHours(Attribute attr)
    {
        byte[] raw = attr.getValueByteArray();
        String[] days = new String[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
        ArrayList<String> ret = new ArrayList<String>();
    
        for (int day = 0 ; day < days.length ; day++) {
            byte[] vBits;
            if (day == 6) {
                vBits = new byte[] { raw[19], raw[20], raw[0] };
            } else {
                vBits = new byte[] { raw[day*3+1], raw[day*3+2], raw[day*3+3] };
            }
    
            StringBuffer sb = new StringBuffer();
            sb.append(String.format("%s:", days[day]));
            for (int b = 0 ; b < 3 ; b++) {
                sb.append(" ");
                sb.append(decodeLogonBits(vBits[b]));
            }
            ret.add(sb.toString());
        }
    
        String[] r = new String[ret.size()];
        ret.toArray(r);
        return r;
    }
    
    private String decodeLogonBits(byte b) {
        StringBuffer sb = new StringBuffer();
        sb.append((b & 0x01) > 0 ? "1" : "0");
        sb.append((b & 0x02) > 0 ? "1" : "0");
        sb.append((b & 0x04) > 0 ? "1" : "0");
        sb.append((b & 0x08) > 0 ? "1" : "0");
        sb.append((b & 0x10) > 0 ? "1" : "0");
        sb.append((b & 0x20) > 0 ? "1" : "0");
        sb.append((b & 0x40) > 0 ? "1" : "0");
        sb.append((b & 0x80) > 0 ? "1" : "0");
        return sb.toString();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to decode a json string returned from flickr within my PHP code.
I am trying to decode a colored QR code in Java with ZXing library.
I have some JSON that I am trying to decode -- it is correctly
I am trying to decode audio samples from various file formats using ffmpeg. Therefore
I'm in the process of trying to decode some assembly code generated from a
I'm trying to decode a char · using charset GB2312 in java this char
I'm trying to decode JSON received from twitter streaming API using JSONConvert from NewtonSoft.Json
I'm trying to download imags from a url and then decode them. The problem
I am trying to decode UPS Maxicode in java and getting the following result
I am trying to decode a string I took from file: file = open

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.