I have this script:
------------------------------------------------------
Option Explicit
On Error Resume Next
Dim wshNetwork, wshFileSystem, wshShell
Dim strUserName
Set wshNetwork = Wscript.CreateObject("Wscript.Network")
strUserName = wshNetwork.UserName
Set objUser = GetObject("LDAP://cn=userA ,ou=Users,ou=Branch,ou=Company,dc=somedomain,dc=com")
Wscript.Echo "Department: " & objUser.Department
---------------------------------------------------------
Instead of userA in the LDAP string I need to use the variable strUserName so I can get the department name based on the user logging in.
I tried this:
1. Set objUser = GetObject("LDAP://cn=strUserName ,ou=Users,ou=Branch,ou=Company,dc=somedomain,dc=com")
2. Set objUser = GetObject("LDAP://cn=" & strUserName & " ,ou=Users,ou=Branch,ou=Company,dc=somedomain,dc=com")
both didn't work. However when I put the actual username then everything works fine. so I just need to insert a variable there. I am not a huge VB scripter therefore I need some assisstance. Please help me out.
------------------------------------------------------
Option Explicit
On Error Resume Next
Dim wshNetwork, wshFileSystem, wshShell
Dim strUserName
Set wshNetwork = Wscript.CreateObject("Wscript.Network")
strUserName = wshNetwork.UserName
Set objUser = GetObject("LDAP://cn=userA ,ou=Users,ou=Branch,ou=Company,dc=somedomain,dc=com")
Wscript.Echo "Department: " & objUser.Department
---------------------------------------------------------
Instead of userA in the LDAP string I need to use the variable strUserName so I can get the department name based on the user logging in.
I tried this:
1. Set objUser = GetObject("LDAP://cn=strUserName ,ou=Users,ou=Branch,ou=Company,dc=somedomain,dc=com")
2. Set objUser = GetObject("LDAP://cn=" & strUserName & " ,ou=Users,ou=Branch,ou=Company,dc=somedomain,dc=com")
both didn't work. However when I put the actual username then everything works fine. so I just need to insert a variable there. I am not a huge VB scripter therefore I need some assisstance. Please help me out.