Tag Archives: group

vSphere: Remove orphaned user from an sso group by command line

Hi,

after migrating a vSphere vCenter instance from Windows to the VCSA appliance some (Windows local user which do no longer exists on linux) orphaned user are member of an SSO group.

Continue reading vSphere: Remove orphaned user from an sso group by command line

Advertisment to support michlstechblog.info

Windows: Get all groups a user is memberof by dsquery/dsget recursive

Hi,

The “net” builtin commands of Windows have some limitations: It truncates groupnames longer then 20 Characters, it cannot resolve group in group memberships….

dsget/dsquery are (LDAP) command line interfaces for active directory. For using these commands you have to install the Windows RSAT Tools (Remote Server Administration Tools).

Some examples.
Continue reading Windows: Get all groups a user is memberof by dsquery/dsget recursive

Powershell: List members of an Active Directory Group

Hi,

here are the code snippets to list all members of an Active Directory Group.

Some constants

# Define LDAP search root, the Global catalog of the domain
$sLDAPSearchRoot="LDAP://yourDomain.com:3268"
# The Groupname to looking for
$sGroupName="USR_GRP_IN_AD"

Continue reading Powershell: List members of an Active Directory Group

Windows: Create a new local User Account and add them to a local group by using .NET and C#

Hi,

a short post. It describes how to create a new local Windows User account and add them to an existing local user group.

First of all, include the following references in your project:


using System.DirectoryServices;
using System.Runtime.InteropServices;

Create a new User with local administrator rights.

// define Username and Password
const string USER_NAME = "NewAdmin";
char[] aPWchars = { 'P', 'a', 's', 's' , 'w', 'o', 'r', 'd'};
System.Security.SecureString oPW = new System.Security.SecureString();
foreach (char cChr in aPWchars) {
    oPW.AppendChar(cChr);
}
// Get Computerobject via ADSI
DirectoryEntry oComputer = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
// New User
DirectoryEntry oNewUser = oComputer.Children.Add(USER_NAME, "user");
// define Pointer to a string
IntPtr pString = IntPtr.Zero;
// Pointer to password
pString = Marshal.SecureStringToGlobalAllocUnicode(oPW);
// Set password
oNewUser.Invoke("SetPassword", new object[] { Marshal.PtrToStringUni(pString) });
// Add a description
oNewUser.Invoke("Put", new object[] { "Description", "New Administrator" });
// Save changes
oNewUser.CommitChanges();
// Cleanup and free Password pointer
Marshal.ZeroFreeGlobalAllocUnicode(pString);
// Get Group
DirectoryEntry oGroup = oComputer.Children.Find("Administrators", "group");
// And add the recently created user
oGroup.Invoke("Add", new object[] { oNewUser.Path.ToString() });

Michael