Paco Posted February 19, 2015 Report Share Posted February 19, 2015 Deal All, I really hope that someone can help on it I would like, from a user name to get the corresponding e-mail address the idea is to provide to my VI: domain name user name eventually the password if really necessary and get as result the e-mail address. In attachment you can see what I already try by using the .NET System.DirectoryServices.AccountManagement but unfortunately as result I get an empty string If you have one alternative solution to query the Active Directory please let me know thank you in advance, best regards, Paco Quote Link to comment
Paco Posted March 12, 2015 Author Report Share Posted March 12, 2015 Final solution was to do a dll with the below VB code and call it by labview. original code I found on neophob.com Dim adoLDAPCon, _ adoLDAPRS, _ strLDAP Public Function GetEmail(strAccountName As String, strDomainName As String) As String Set adoLDAPCon = CreateObject("ADODB.Connection") adoLDAPCon.Provider = "ADsDSOObject" adoLDAPCon.Open "ADSI" strLDAP = "'LDAP://" & strDomainName & "'" Set adoLDAPRS = adoLDAPCon.Execute("select mail from " & strLDAP & " WHERE objectClass = 'user'" & " And samAccountName = '" & strAccountName & "'") With adoLDAPRS If Not .EOF Then GetEmail = .Fields("mail") Else GetEmail = "" End If End With adoLDAPRS.Close Set adoLDAPRS = Nothing Set adoLDAPCon = Nothing End Function Quote Link to comment
ned Posted March 12, 2015 Report Share Posted March 12, 2015 In case you want it, here's that VB code translated into LabVIEW (2012) so you don't need a separate DLL: EmailFromUserName.vi Quote Link to comment
Paco Posted March 16, 2015 Author Report Share Posted March 16, 2015 Hi Ned! Thank you very much, I have tested your VI and it's working perfectly :D I was not able to translate it in LabView code by myself thank you again Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.