cancel
Showing results for 
Search instead for 
Did you mean: 

System - Active Directory VBO Help

faheemsd
MVP

Dear Team,

Currently we have the System - Active Directory  VBO as in which we can perform the Operations 

like

  • Create User
  • User Exists
  • User Exists (Display Name)
  • User Exists (user Principle Name)
  • Object Exist (Dynamic)
  • Add User to Group

Here I need help from you to create one page for getting the Active Directory (AD) user details like First Name, Last Name and Email Id of the user

Could you please help me on this?



------------------------------
SYED FAHEEM
RPA Developer
DAR-ME
Asia/Kolkata
------------------------------
1 BEST ANSWER

Helpful Answers

Hi Syed,

Can you try the below code stage to get the First Name, Last Name and Mail ID. You can refer the LDAP attribute names from here.

Input :

23556.png

Output :

23557.png

Code:

firstName = ""
lastName  = ""
mailID    = ""
Dim ds As New DirectoryServices.DirectorySearcher("(userPrincipalName=" & SearchString & ")")
ds.PropertiesToLoad.Add("givenName") ' First Name
ds.PropertiesToLoad.Add("sn") ' Last Name
ds.PropertiesToLoad.Add("mail") ' Mail
Exists = ds.FindOne() IsNot Nothing
Dim result As SearchResult = ds.FindOne()
    If Exists Then
        Dim properties As ResultPropertyCollection = result.Properties
        ' Get the first name, last name, mail attributes
        firstName = properties("givenName")(0)?.ToString()
        lastName = properties("sn")(0)?.ToString()
        mailID = properties("mail")(0)?.ToString()
    End If



------------------------------
Athiban Mahamathi - https://www.linkedin.com/in/athiban-mahamathi-544a008b/
Technical Consultant,
SimplifyNext,
Singapore
------------------------------

View answer in original post

6 REPLIES 6

Hi Syed,

Can you try the below code stage to get the First Name, Last Name and Mail ID. You can refer the LDAP attribute names from here.

Input :

23556.png

Output :

23557.png

Code:

firstName = ""
lastName  = ""
mailID    = ""
Dim ds As New DirectoryServices.DirectorySearcher("(userPrincipalName=" & SearchString & ")")
ds.PropertiesToLoad.Add("givenName") ' First Name
ds.PropertiesToLoad.Add("sn") ' Last Name
ds.PropertiesToLoad.Add("mail") ' Mail
Exists = ds.FindOne() IsNot Nothing
Dim result As SearchResult = ds.FindOne()
    If Exists Then
        Dim properties As ResultPropertyCollection = result.Properties
        ' Get the first name, last name, mail attributes
        firstName = properties("givenName")(0)?.ToString()
        lastName = properties("sn")(0)?.ToString()
        mailID = properties("mail")(0)?.ToString()
    End If



------------------------------
Athiban Mahamathi - https://www.linkedin.com/in/athiban-mahamathi-544a008b/
Technical Consultant,
SimplifyNext,
Singapore
------------------------------

@Athiban Mahamathi Mathialagan

Thank you for your response.



------------------------------
SYED FAHEEM
RPA Developer
DAR-ME
Asia/Kolkata
------------------------------

@Athiban Mahamathi Mathialagan

I'm not getting any results with the above code and it's sowing the Exist flag as false.

The user details already exist in the AD group.



------------------------------
SYED FAHEEM
RPA Developer
DAR-ME
Asia/Kolkata
------------------------------

@Athiban Mahamathi Mathialagan

I'm getting the AD details with the below code

 
firstName = ""
lastName  = ""
mailID    = ""
Dim ds As New DirectoryServices.DirectorySearcher("(samAccountName=" & SearchString & ")")
ds.PropertiesToLoad.Add("givenName") ' First Name
ds.PropertiesToLoad.Add("sn") ' Last Name
ds.PropertiesToLoad.Add("mail") ' Mail
Exists = ds.FindOne() IsNot Nothing
Dim result As SearchResult = ds.FindOne()
    If Exists Then
        Dim properties As ResultPropertyCollection = result.Properties
        ' Get the first name, last name, mail attributes
        firstName = properties("givenName")(0)?.ToString()
        lastName = properties("sn")(0)?.ToString()
        mailID = properties("mail")(0)?.ToString()
    End If


------------------------------
SYED FAHEEM
RPA Developer
DAR-ME
Asia/Kolkata
------------------------------

Glad that it worked out.



------------------------------
Athiban Mahamathi - https://www.linkedin.com/in/athiban-mahamathi-544a008b/
Technical Consultant,
SimplifyNext,
Singapore
------------------------------

Miyelani
Level 2

Hi

i need help with the code stage to extend the Active Directory object to be able to delete users and to set the expiry date on user accounts