Skip to content

New-CMDB User creates user without SMTP notification (email)#477

Draft
pwahlmueller wants to merge 2 commits into
AdhocAdam:v5from
pwahlmueller:primary
Draft

New-CMDB User creates user without SMTP notification (email)#477
pwahlmueller wants to merge 2 commits into
AdhocAdam:v5from
pwahlmueller:primary

Conversation

@pwahlmueller

@pwahlmueller pwahlmueller commented Oct 16, 2023

Copy link
Copy Markdown
  1. Since the SMTP notification was not in all cases unique, I added
    a. the domain
    b. a guid (to be absolute on the safe side)

  2. And I added error handling in case, somthing still fails.

Here in addition the scenario, which fails:

  1. Send email with patrick@mydomain.com which is not yet in CMDB -> notification newid gets patrick_SMTP
  2. Send email with patrick@myNEWdomain.com which is not yet in CMDB ->notification newid gets patrick_SMTP -> fails adding notification

@pwahlmueller pwahlmueller changed the title # Id should be unique New-CMDB User creates user without SMTP notification (email) Oct 16, 2023
@AdhocAdam AdhocAdam changed the base branch from primary to dev October 22, 2023 18:55
@AdhocAdam AdhocAdam self-assigned this Nov 6, 2023
@AdhocAdam AdhocAdam added this to the ??? milestone Nov 6, 2023
@AdhocAdam

Copy link
Copy Markdown
Owner

I feel like you are onto something here by forcing the ID to be unique with a GUID. But the thing is, I can't reproduce the scenario you're referring to above as the ID I'm seeing is still unique with the domain name + username.

I copied the New-CMDBUser function out, introduced a Write-Host for the $newID variable, and then ran it with both examples. In which case, that arguably becomes a question of "how is the email not being found which leads to incorrectly calling New-CMDBUser." I'm genuinely not sure if that's the issue as this whole thing has been hard to pin down. The last thing I recall in this space was the update made to Get-SCSMUserByEmailAddress wherein SMLets was incorrectly evaluating hyphens in email addresses.

result

In any case, the only way I can produce an error is if I don't delete those users from SCSM, and then run the example again. In which case, duplicate users are created with empty Notification Channels.

Note: Ignore the Problems 1 in the above screenshot. I have a few things open 😄

@pwahlmueller

pwahlmueller commented Dec 1, 2023

Copy link
Copy Markdown
Author

You are completly right, the id would be unique with domain name + username.
But in the actual script only the username was used, which causes the issue.
I wonder that you can add both users with the actual script - could you?
The main reason to add the guid was, that I'm absolut sure the id will be unique in the prod env of the customer.

But I can do a script in my test environment to double check it and provide it here, if this helps.

@AdhocAdam

Copy link
Copy Markdown
Owner

But in the actual script only the username was used, which causes the issue

Are you referring to the following line in New-CMDBUser? or somewhere else?

https://github.com/AdhocAdam/smletsexchangeconnector/blob/02be0b1aed028647848c982e19ae5779c7596822/smletsExchangeConnector.ps1#L2916C9-L2916C209

I wonder that you can add both users with the actual script - could you?

Sure. So add the two users via script and then?

The main reason to add the guid was, that I'm absolut sure the id will be unique in the prod env of the customer.
But I can do a script in my test environment to double check it and provide it here, if this helps.

Like I said, I am strongly inclined to agree with you here on this change. I just want to see it for myself is all 😁 but if you can validate that's helpful as well 👍

@AdhocAdam AdhocAdam changed the base branch from dev to v5 January 25, 2026 03:37
@AdhocAdam AdhocAdam marked this pull request as draft June 25, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants