Adjusted logging in pre-existing method. Added more comments for documentation.
This commit is contained in:
parent
0dd19af900
commit
bd0d378218
@ -503,17 +503,25 @@ Service GetADGroupMembersByGroupName(GroupName, Domain=DOMAIN)
|
|||||||
end service
|
end service
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
// VerifyEPPMetrology
|
// GetADUserAttributes
|
||||||
//
|
//
|
||||||
// RDSNo. - [Required]
|
// Username - The exact AD username of the user you are looking for.
|
||||||
|
// Domain - Sets to infineon by Default. override with and string value
|
||||||
//
|
//
|
||||||
// Sets an error in Error_Services if there is an issue with the metrology data.
|
// Searches for a matching user in Active Directory and returns a user with @VM delimited attributes.
|
||||||
|
// First value is the AD User Name, Second value is the Display Name, and third value is the email.
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
Service GetADUserAttributes(Username, Domain)
|
Service GetADUserAttributes(Username, Domain=DOMAIN)
|
||||||
Set_Status(0)
|
Set_Status(0)
|
||||||
ThisUser = ''
|
ThisUser = ''
|
||||||
ErrMessage = ''
|
ErrMessage = ''
|
||||||
If Username NE '' AND Domain NE '' then
|
If Username EQ '' then
|
||||||
|
ErrMessage = 'Username was null.'
|
||||||
|
end
|
||||||
|
If Domain EQ '' then
|
||||||
|
Domain = 'INFINEON'
|
||||||
|
end
|
||||||
|
If ErrMessage EQ '' then
|
||||||
DotNetHandle = StartDotNet("","4.0")
|
DotNetHandle = StartDotNet("","4.0")
|
||||||
DotNetDir = CheckDotNet('4.0'):'\'
|
DotNetDir = CheckDotNet('4.0'):'\'
|
||||||
AccountMgmtDllPath = DotNetDir:'System.DirectoryServices.AccountManagement.dll'
|
AccountMgmtDllPath = DotNetDir:'System.DirectoryServices.AccountManagement.dll'
|
||||||
@ -530,62 +538,59 @@ Service GetADUserAttributes(Username, Domain)
|
|||||||
If Not(Get_Status(errCode)) then
|
If Not(Get_Status(errCode)) then
|
||||||
objUserPrincipal = Send_Message.Net(objPrinSearcher, 'FindOne', '', '', 1)
|
objUserPrincipal = Send_Message.Net(objPrinSearcher, 'FindOne', '', '', 1)
|
||||||
If Not(Get_Status(errCode)) then
|
If Not(Get_Status(errCode)) then
|
||||||
UserName = Get_Property.Net(objUserPrincipal, 'Name', 0)
|
ADUserName = Get_Property.Net(objUserPrincipal, 'Name', 0)
|
||||||
Email = Get_Property.Net(objUserPrincipal, 'EmailAddress', 0)
|
Email = Get_Property.Net(objUserPrincipal, 'EmailAddress', 0)
|
||||||
DisplayName = Get_Property.Net(objUserPrincipal, 'DisplayName', 0)
|
DisplayName = Get_Property.Net(objUserPrincipal, 'DisplayName', 0)
|
||||||
ThisUser<1> = UserName
|
ThisUser<1> = ADUserName
|
||||||
ThisUser<2> = DisplayName
|
ThisUser<2> = DisplayName
|
||||||
ThisUser<3> = Email
|
ThisUser<3> = Email
|
||||||
end else
|
end else
|
||||||
//Error getting user object
|
//Error getting user object
|
||||||
LogData = ''
|
ErrMessage = 'Error getting user attributes of user: ' : Username : ' within the ' : Domain : ' domain.'
|
||||||
LogData<1> = LoggingDTM
|
|
||||||
LogData<2> = 'GetADUserAttributes'
|
|
||||||
LogData<3> = 'Error getting user attributes of user: ' : Username : ' within the ' : Domain : ' domain.'
|
|
||||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
|
||||||
end
|
end
|
||||||
Free_class.Net(objPrinSearcher)
|
Free_class.Net(objPrinSearcher)
|
||||||
end else
|
end else
|
||||||
//error creating principle searcher
|
//error creating principle searcher
|
||||||
LogData = ''
|
ErrMessage = 'Error creating principle searcher. Username: ' : Username : ' within the ' : Domain : ' domain.'
|
||||||
LogData<1> = LoggingDTM
|
|
||||||
LogData<2> = 'GetADUserAttributes'
|
|
||||||
LogData<3> = 'Error creating principle searcher. Username: ' : Username : ' within the ' : Domain : ' domain.'
|
|
||||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
|
||||||
end
|
end
|
||||||
Free_Class.Net(objUserPrincipal)
|
Free_Class.Net(objUserPrincipal)
|
||||||
end else
|
end else
|
||||||
//error creating user principle object
|
//error creating user principle object
|
||||||
LogData = ''
|
ErrMessage = 'Error creating principle searcher. Username' : Username : 'within the ' : Domain : ' domain.'
|
||||||
LogData<1> = LoggingDTM
|
|
||||||
LogData<2> = 'GetADUserAttributes'
|
|
||||||
LogData<3> = 'Error creating principle searcher. Username' : Username : 'within the ' : Domain : ' domain.'
|
|
||||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
|
||||||
end
|
end
|
||||||
Free_Class.Net(objPC)
|
Free_Class.Net(objPC)
|
||||||
end else
|
end else
|
||||||
//Error creating principle context
|
//Error creating principle context
|
||||||
LogData = ''
|
ErrMessage = 'Error creating principle context Username' : Username : 'within the ' : Domain : ' domain.'
|
||||||
LogData<1> = LoggingDTM
|
|
||||||
LogData<2> = 'GetADUserAttributes'
|
|
||||||
LogData<3> = 'Error creating principle context Username' : Username : 'within the ' : Domain : ' domain.'
|
|
||||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
|
||||||
end
|
end
|
||||||
end else
|
end else
|
||||||
//error calling dotnet
|
//error calling dotnet
|
||||||
|
ErrMessage = 'Error creating dotnet object. Username' : Username : 'within the ' : Domain : ' domain.'
|
||||||
|
end
|
||||||
|
If ErrMessage EQ '' then
|
||||||
|
Message = 'Successfully retrieved attributes of user ' : Username : ' within the ' : Domain : ' domain.'
|
||||||
LogData = ''
|
LogData = ''
|
||||||
LogData<1> = LoggingDTM
|
LogData<1> = LoggingDTM
|
||||||
LogData<2> = 'GetADUserAttributes'
|
LogData<2> = 'GetADUserAttributes'
|
||||||
LogData<3> = 'Error creating dotnet object. Username' : Username : 'within the ' : Domain : ' domain.'
|
LogData<3> = Message
|
||||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
||||||
|
end else
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM
|
||||||
|
LogData<2> = 'GetADUserAttributes'
|
||||||
|
LogData<3> = 'Error getting attributes of user ' : Username : ':' : ErrMessage
|
||||||
|
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
||||||
|
Error_Services('Add', ErrMessage)
|
||||||
end
|
end
|
||||||
end else
|
end else
|
||||||
//Error, missing username or domain name
|
//Error, missing username or domain name
|
||||||
LogData = ''
|
LogData = ''
|
||||||
LogData<1> = LoggingDTM
|
LogData<1> = LoggingDTM
|
||||||
LogData<2> = 'GetADUserAttributes'
|
LogData<2> = 'GetADUserAttributes'
|
||||||
LogData<3> = 'Missing username or domain name'
|
LogData<3> = 'Error getting user attributes: ' : ErrMessage
|
||||||
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
Logging_Services('AppendLog', objADLog, LogData, @RM, @FM, False$)
|
||||||
|
Error_Services('Add', ErrMessage)
|
||||||
end
|
end
|
||||||
Response = ThisUser
|
Response = ThisUser
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user