// creates a user in Azure with a minimal number of properties set
func CreateBaseAzureUser(strDisplayName, strMailNickName, strUserPrincipleName, strPassword, strEmployeeId string)(error){
logger.NLog.Info().Msg("CreateBaseAzureUser Started: dn: " + strDisplayName + " mnn: " + strMailNickName + " upn: " + strUserPrincipleName + " eid: " + strEmployeeId)
//employee id check: check if there is already a current user with the same employee id
//get the base azure user properties by employeeId
user, err := AzureGetBaseUsersByPropertyFilter("employeeId", strEmployeeId)
if user != nil {
if len(user.GetValue()) != 0 {
logger.NLog.Error().Err(err).Msg("CreateBaseAzureUser Error: " + strEmployeeId)
strM := "An Azure user with the employeeID " + strEmployeeId + " already exits."
utils.PostMessageT("it-help@internews.org", "Azure Account Creation Error for Emp. ID: " + strEmployeeId, strM)
return errors.New(strM)
}
}
requestBody := graphmodels.NewUser()
accountEnabled := true
// Enable the account
requestBody.SetAccountEnabled(&accountEnabled)
// Display Name
requestBody.SetDisplayName(&strDisplayName)
// Mail Nick Name
requestBody.SetMailNickname(&strMailNickName)
// User Principal Name
requestBody.SetUserPrincipalName(&strUserPrincipleName)
// Employee ID
requestBody.SetEmployeeId(&strEmployeeId)
// Password
passwordProfile := graphmodels.NewPasswordProfile()
forceChangePasswordNextSignIn := true
passwordProfile.SetForceChangePasswordNextSignIn(&forceChangePasswordNextSignIn)
passwordProfile.SetPassword(&strPassword)
requestBody.SetPasswordProfile(passwordProfile)
if azureGgraphConnector == nil{
err := InitializeAzureGraph()
if err != nil{
logger.NLog.Error().Err(err).Msg("CreateBaseAzureUser InitializeAzureGraph Error")
utils.PostMessageT("it-help@internews.org", "CreateBaseAzureUser InitializeAzureGraph Error for Emp. ID: " + strEmployeeId, err.Error())
return err
}
}
users, err := azureGgraphConnector.AppClient.Users().Post(context.Background(), requestBody, nil)
if err != nil {
logger.NLog.Error().Err(err).Msg("CreateBaseAzureUser error: " + strEmployeeId + " " + strDisplayName)
utils.PostMessageT("it-help@internews.org", "Azure Account Creation Error: " + strEmployeeId + " " + strDisplayName, err.Error())
return err
} else {
logger.NLog.Info().Msg("CreateBaseAzureUser user created: " + *users.GetDisplayName())
}
return nil
}
No words wasted! Getting to the point about the work I do, the problems I deal with, and some links to posts about where I work.
Translate
Monday, October 21, 2024
Golang - Create Azure User
Function to ccreate a new user account in Azure using msgraph-sdk-go:
Friday, September 13, 2024
TSQL - Update Using A List of Values
I needed to update around 800 addresses from a list of addresses in a spreadsheet. I saved the spreadsheet as csv and then formated the csv fields into a list of values. Then I wrote an SQL select statement that took the list of values and made it into a subquery that I could join on the address table.
This is the finale SQL with just a subset of the values:
This is the finale SQL with just a subset of the values:
update aglA
set aglA.telephone = lh.phone
from address aglA
join (select * from (values('100000','1 707 822 4226'),('100010','1 707 826 9681'),('100030','1 707 445 8248'))as x( res_id, phone))lh on lh.res_id = aglA.res_id
Wednesday, February 28, 2024
Salesforce - Export Developer Console Query Results
After the query is run, rught click on the query results and select Inspect. Look for the table tag, and then click Copy and then Copy element. Paste the copied results into Excel.
Subscribe to:
Posts (Atom)