Skip to main content
Share Your Experience: Take the 2024 Developer Survey
7 votes
Accepted

LDAP Login Script

Logical inconsistencies and careless mistakes Let's look at the outline: ...
200_success's user avatar
6 votes

Adding some properties to an Active Directory user

Disclaimer: I never wrote code like that, I do not see a reason to do it and I discourage everyone to do it. This however may be seen as nothing else aside of a preference. But what are you trying to ...
Bruno Costa's user avatar
  • 5,566
5 votes

Get users from groups in active directory, disposing of everything

You can remove braces between using statements, leaving the last one. That would help you to remove a few of lines, but still not so deeply. Wrapping the ...
extremecsharper's user avatar
4 votes

Code Behind to manage AD users for a CRM system

Do NOT use Hungarian notation: bAccionOk, sPassword,... Do NOT use non-alphanumeric characters: ...
BCdotWEB's user avatar
  • 11.2k
4 votes

Get users from groups in active directory, disposing of everything

like ExtremeCSharper said, you can remove some of the Curly Braces for the using statements. you should also return as soon as possible, so inside the using statement. this is how I would clean it up ...
Malachi's user avatar
  • 28.6k
4 votes

LDAP Login Script

1) private function dologinWithPostData() { I would pass in login credentials to the method so you don't have some arbitrary class method directly accessing ...
Mike Brant's user avatar
  • 9,608
4 votes
Accepted

Extension methods to get direct reports from user

Why are you ToListing your collections when you are returning IEnumerable<T>? Unless you have a good reason (rare) then ...
pm100's user avatar
  • 791
4 votes
Accepted

Building a string representing 50+ ActiveDirectory options

You can put the switch-cases into a dictionary to reduce the boilerplate case and break. The ...
Xiaoy312's user avatar
  • 3,136
4 votes
Accepted

Adding some properties to an Active Directory user

I think that's fine. The dot operator is an operator like any other, so you can line it up if you think that will improve readability. It's particular useful for "fluent" style method calls: ...
Dangph's user avatar
  • 1,683
3 votes
Accepted

Active Directory Query Application

"Backend" is a compound word and thus the correct capitalization should be "BackEnd". However, that would still be a fairly meaningless name for a class, even for a namespace. Your ...
BCdotWEB's user avatar
  • 11.2k
3 votes
Accepted

Active Directory Query Application - Take 2

It seems that your backgroundWorker is fiddling with UI elements, although the only thing he does is to show a MessageBox. I do not know if this is safe or not, but ...
Bruno Costa's user avatar
  • 5,566
3 votes

Automating New User Creation With C# Web Service

My biggest concerns are that I miss some data validation. Sure you say that FirstName and LastName won't be null, but they may ...
Heslacher's user avatar
  • 50.4k
3 votes
Accepted

Active Directory Tool - WPF application to query active directory and display results

Only scratching the surface... ActiveDirectoryScope The AddDirectoryScope() method can be improved by storing the value of the ...
Heslacher's user avatar
  • 50.4k
3 votes
Accepted

Automating New User Creation With C# Web Service

I would not put dependency on singleton in this class – it means two responsibility for NewUser - format properties and orchestrate AD API. Let’s define this helper ...
Dmitry Nogin's user avatar
  • 6,131
3 votes
Accepted

Getting Windows User Info From The Active Directory

Very clean code, reads very nicely, well done! Watch for inconsistencies in indentation: Public Sub PrintToImmediateWindow() With this ...
Mathieu Guindon's user avatar
3 votes
Accepted

Checks if user is part of Active Directory group

OnAuthorization() If the possibility exists that HttpContext.Current.User.Identity.Name dosn't contain \ the call to ...
Heslacher's user avatar
  • 50.4k
2 votes

Automating New User Creation With C# Web Service

This annoys me: public readonly string FullName; And that's because readonly is a modifier for fields. Instead, I'd expect ...
BCdotWEB's user avatar
  • 11.2k
2 votes
Accepted

Many similar ViewModel methods to fetch and prepare model data

The methods should return Task instead of void. Otherwise exception are shallowed. Alternative you could encapsulate the whole ...
JanDotNet's user avatar
  • 8,538
2 votes
Accepted

Active Directory Tool - Wpf application to query active directory and display results 2 (UI)

You set some of the properties to their default values. For example Button's alignments are Top and ...
Nikita B's user avatar
  • 13k
2 votes

Active Directory Query Application

First thing that I saw that you could make a little easier to read and less verbose is this ...
Malachi's user avatar
  • 28.6k
2 votes
Accepted

Create share folder and AD security group and apply security to new folder

Advanced Functions I would have a serious look at the about_advanced_function_parameters. In the beginning you are doing some parameter validation on read-host ...
Matt's user avatar
  • 2,558
2 votes
Accepted

Retrieving data from active directory with PHP

There certainly are ways to break this down to more understandable chunks, in fact, there are refactoring techniques that address your specific issue, long method. You can look at https://refactoring....
Oli's user avatar
  • 296
2 votes

Powershell script that updates Active Directory user information

I agree with what @veefu suggests, and would like to build off that. To start with, you have different columns in your CSV as to what Set-ADUser is expecting. To ...
TheMadTechnician's user avatar
2 votes

Code Behind to manage AD users for a CRM system

Any suggestions for refactoring, not code-smell... If you want to refactor your code you should start with code-smell. Currently it looks like at least four or five developers each with different ...
t3chb0t's user avatar
  • 44.3k
2 votes

Pulling data from a CSV and populate AD

Separate data and code As a general rule, you should separate your data and your code. You said in a comment that you were unhappy with the switch statement, so I ...
Dangph's user avatar
  • 1,683
2 votes

Get all AD groups and Exchange features of users

The lack of proper indentation hides the fact that for each user you request all the members of every group. That's 15000*1000 = 15 million remote calls, most of which redundant. Even if 100 calls ...
D. Jurcau's user avatar
  • 3,010
2 votes
Accepted

Bindling User details from AD using LDAP

General Guidelines Please put any technical restrictions in the initial post. Like, for instance, framework 3.5 :-( Declare variables as var rather than their type ...
dfhwze's user avatar
  • 13.9k
2 votes

PowerShell script creates a computer list from an AD OU, and add exclusions to a specific file via Invoke-Command

Your try block will be unable to pass the error to catch block if you don't use -ErrorAction Stop. Also there is an ...
Wasif's user avatar
  • 141
2 votes

PowerShell script creates a computer list from an AD OU, and add exclusions to a specific file via Invoke-Command

Instead of the try-catch block (or in addition to), you can check if the last command was successful by checking the value of $?. If it's not true, you can output your desired error message. ...
philselmer's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible