I am trying to use a function I wrote in Python that connects to AD and pulls back specific user information for account creation. I know the function works correctly in python, but I am not able to get any of the return information to appear in a message box. UiPath does not throw any errors but does not stop running either. Below is the Function from python. Please let me know if any additional information would be of assistance.
from pyad import*
from nameparser import HumanName
from nameparser.config import CONSTANTS
from DAT_Automation_DEP.States import StatesL
import pyad.adquery
#Searching user in AD
def AD(UserName):
q = pyad.adquery.ADQuery()
q.execute_query(
attributes = [“cn”, “mail”, “st”, “telephoneNumber”],
where_clause = f"SamAccountName = ‘{UserName}’",
base_dn=“DC=ABC,DC=com”
)
for row in q.get_results():
name = row[“cn”]
email = row[“mail”]
st = row[“st”]
ext = row[“telephoneNumber”]
#Parses name for initials
def initials(full_name):
initial=“”
if (len(full_name) == 0):
return
first_middle_last = full_name.split(" ")
for name in first_middle_last:
initial=initial+name[0].upper()+""
return initial
print(name)
DATint = initials(name)
#Splits First / Last Name into own text values
Hname = HumanName(name)
Hname = Hname
FirstN = Hname.first
LastN = Hname.last
#Parses TQL Username from Email
DatUsrNameAD = (email.split(‘@’))
DatUsrName = DatUsrNameAD.pop(0)
return DatUsrName, FirstN, LastN, DATint, st, ext, email, name