We have an automation script where a user (who is logged in via a AD domain account) clicks a button to activate a system. So we know who did what, we require the user to enter their username and a phone number in which they can be reached should we see an issue. the users would like to further streamline this process and not have to enter this information but still have this information. If we add the phone number to the users' domain account information, is there a way in Automation to pull this information back out of the domain account?
Hi Nikolas,
This is possible using the Automation script engine in DataMiner. You can create an automation script that uses a C# action to read the user's phone number (assuming it's available in the Active Directory for said user):
var userFullName = engine.SendSLNetSingleResponseMessage(new GetUserFullNameMessage()) as GetUserFullNameResponseMessage;
var userInfo = engine.SendSLNetSingleResponseMessage(new GetInfoMessage(InfoType.SecurityInfo)) as GetUserInfoResponseMessage;
var currentUser = userInfo.Users.FirstOrDefault(u => u.FullName == userFullName.User);
engine.GenerateInformation("Current user's phone is " + currentUser.PhoneNumber);
What namespace needs to be included for GetUSerFullNameMessage and GetUserFullNameResponseMessage? An error gets thrown on those.
using Skyline.DataMiner.Net.Messages
almost there.
Now I get an error about the FirstOrDefault
The following was returned from the script:
(after retries) (Code: 0x80040251) Skyline.DataMiner.Net.Exceptions.DataMinerException: No Assembly found for cookie 3
(86,30): error CS1061: ‘DataMinerUser[]’ does not contain a definition for ‘FirstOrDefault’ and no accessible extension method ‘FirstOrDefault’ accepting a first argument of type ‘DataMinerUser[]’ could be found (are you missing a using directive or an assembly reference?)
That method is located in de System.Linq namespace
It appears that currentUser is null.
userInfo returns: User Info: 12 User(s), 3 Group(s).
Accessing the next line (currentUser) returns blank. If I try to access the member PhoneNumber like in your example, I get a Null Reference Exception.
As this question has been inactive for a long time, we will now close it. If you want further assistance, feel free to post a new question or contact techsupport@skyline.be.