Customizing Navigation Bar Appreance using SwiftUI

If you are having trouble trying to customize the navigation appearance like I have been.

You can use the following code, I have been placing my code in its own function and calling from the delegate function application(application:launchOptions:).

func customNavigationAppearance() {
     let appearance = UINavigationBarAppearance()

     appearance.configureWithOpaqueBackground()
     appearance.backgroundColor = .black
     appearance.titleTextAttributes = [ .foregroundColor: UIColor.white ]
     appearance.largeTitleTextAttributes = [ .foregroundColor: UIColor.white ]

     UINavigationBar.appearance().tintColor = .white
     UINavigationBar.appearance().backgroundColor = .black
     UINavigationBar.appearance().standardAppearance = appearance
     UINavigationBar.appearance().scrollEdgeAppearance = appearance
}

You can create another appearance for when your navigation is in a scrolled state by setting standardAppearance to an object with your appearance preferences.

Colour appropriately.

Jun 11th, 2020 • Filed under Apple, iOS, SwiftUI

Reduce Array to String for Text and Other Views

If you ever need to concatenate an array of strings for formatting in SwiftUI view, you can use the reduce() function, like this:

let words = ["Hello", "World"]

var body: some View {
    words.reduce(Text(""), { $0 + Text($1) + Text(" ")} ) }
}

$0 = First parameter of reduce function
$1 = Reduce string

Jun 9th, 2020 • Filed under Apple, iOS, SwiftUI

How-to Investigate Active Directory Logon Mischief

The Windows domain feature for locking accounts can be a helpful feature against malicious attempts to guess a password via brute force.

The version of netlogon.dll that has tracing included is installed by default on all currently supported versions of Windows. To enable debug logging, set the debug flag that you want by using nltest.exe, the registry, or Group Policy.

Group Policy

You will have to adjust a few policy settings to get the DCs to audit logon events. This are usually set correctly, but it can be worth a check of the environment to make sure the DCs are get the proper audit settings.

Audit account logon events for domain accounts and Audit logon events for logons to the computer.

Events

The Event IDs we are most concerned with are under the Windows Logs > Security section of Event Viewer.

  • 4624
  • 4776

If the auditing of Events on Domain Controllers doesn’t reveal the whole story, you can enable debug tracing in the NETLOGON service.

Enable Trace Logging in NETLOGON

If you try audit account logon but the workstation field keeps turning up empty you can enable trace logging on the DC trace debug logs output to C:\Windows\debug\netlogon.log

The log file netlogon.log can grow to 20MB and will be rotated out for a new log file.

To enable and disable trace logging in netlogon service, use the following nltest.exe commands respectively.

nltest.exe /dbflag:2080ffff
nltest.exe /dbflag:0

The following will be written to netlogon.log when you set the flags.

[MISC] [5584] DbFlag is set to 2080ffff

You will find entries these in the netlogon.log file.

[LOGON] [884] X: SamLogon: Transitive Network logon of (null)\ADMIN from (via X) Entered
[LOGON] [884] X: SamLogon: Transitive Network logon of (null)\ADMIN from (via X) Returns 0xC0000064

More information

https://support.microsoft.com/en-us/help/109626/enabling-debug-logging-for-the-netlogon-service

Increase Service Logging

At times it can be help to increase the logging for a given component, like LDAP Interface Events. You have to do this using regedit, under the following key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS\Diagnostics

Conclusion

It can be hard to find logon activity in a Windows environment. But, if you have the right policies enabled and know which debug settings to turn when you need to troubleshoot activity, you will be that much further ahead.

Jun 2nd, 2020 • Filed under Active Directory, Microsoft, Windows Server

Extending iOS 13 UIColor

iOS 13 comes with a new color scheme, and to access the old system colors, you will need to reach for UIColor and maybe create a Color object, like so:

let ourColor = Color(UIColor.systemGray5)

Extending the UIColor class is made easy by switch extension.

extension UIColor {
    var asColor: Color {
        return Color(self)
    }
}

Use it like so:

let ourColor = UIColor.systemGray5.asColor
Jun 2nd, 2020 • Filed under Apple, iOS, Swift, SwiftUI