To use this function add it to the class library file named OrchestratorPluginADService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: OrchestratorPluginADService.ts
Private Function: ADGroupGetAttribute
private ADGroupGetAttribute<T>(objADGroup: AD_Group, strADGroupAttributeName: string): T {
this.objLogger.info(`Getting AD User Group Attribute '${strADGroupAttributeName}'.`);
let anyADGroupAttribute: T = objADGroup.getAttribute(strADGroupAttributeName) as T;
return anyADGroupAttribute;
}Private Function: ADGroupSetAttribute
private ADGroupSetAttribute<T>(objADGroup: AD_Group, strADGroupAttributeName: string, anyADGroupAttributeValue: T): boolean {
this.objLogger.info(`Setting AD User Group Attribute '${strADGroupAttributeName}' with value '${anyADGroupAttributeValue.toString()}'.`);
try {
objADGroup.setAttribute(strADGroupAttributeName, anyADGroupAttributeValue as any);
return true;
}
catch (objException) {
//@ts-ignore
this.objLogger.error(`Failed to set attribute '${strADGroupAttributeName}=${anyADGroupAttributeValue.toString()}' for User Group ${objADGroup.name}\n\t${objException}`);
return false;
}
}Private Function: ADGroupAddAttribute
private ADGroupAddAttribute<T>(objADGroup: AD_Group, strADGroupAttributeName: string, anyADGroupAttributeValue: T): boolean {
this.objLogger.info(`Adding AD User Group Attribute '${strADGroupAttributeName}' with value '${anyADGroupAttributeValue.toString()}'.`);
try {
//@ts-ignore
objADGroup.addAttribute(strADGroupAttributeName, anyADGroupAttributeValue);
return true;
}
catch (objException) {
//@ts-ignore
this.objLogger.error(`Failed to add attribute '${strADGroupAttributeName}=${anyADGroupAttributeValue.toString()}' for User Group ${objADGroup.name}\n\t${objException}`);
return false;
}
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
