 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: AD user details</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/ad-user-details/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/ad-user-details/</link>
	<description></description>
	<lastBuildDate>Thu, 23 May 2013 01:41:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: manishpkj</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/ad-user-details/#comment-93667</link>
		<dc:creator>manishpkj</dc:creator>
		<pubDate>Sat, 25 Jun 2011 12:44:21 +0000</pubDate>
		<guid isPermaLink="false">#comment-93667</guid>
		<description><![CDATA[Hi All................ I have written a VB script that captures all the Tab details (even the groups user belongs to , MemberOf Tab) and export it to Excel. Then, you can import it to MS Access database.............

Dim ObjWb 
 Dim ObjExcel 
Dim MemberOf
Dim objUser, objGroup
Dim strList
Dim objmemberOf
 Dim x, zz 
 Set objRoot = GetObject(&quot;LDAP://RootDSE&quot;) 
 strDNC = objRoot.Get(&quot;DefaultNamingContext&quot;) 
 Set objDomain = GetObject(&quot;LDAP://&quot; &amp; strDNC) &#039; Bind to the top of the Domain using LDAP using ROotDSE 
 
Call ExcelSetup(&quot;Sheet1&quot;) &#039; Sub to make Excel Document 
 x = 1 
 Call enummembers(objDomain) 

 Sub enumMembers(objDomain) 
 On Error Resume Next 
 Dim Secondary(20) &#039; Variable to store the Array of 2ndary email alias&#039;s 
 For Each objMember In objDomain &#039; go through the collection 

 If ObjMember.Class = &quot;user&quot; Then &#039; if not User object, move on. 
 x = x +1 &#039; counter used to increment the cells in Excel     

objwb.Cells(x, 1).Value = objMember.Class 
    &#039; I set AD properties to variables so if needed you could do Null checks or add if/then&#039;s to this code 
    &#039; this was done so the script could be modified easier. 
 SamAccountName = ObjMember.samAccountName 
 Cn = ObjMember.CN 
 FirstName = objMember.GivenName 
 LastName = objMember.sn 
 initials = objMember.initials 
 Descrip = objMember.description 
 Office = objMember.physicalDeliveryOfficeName 
 Telephone = objMember.telephonenumber 
 EmailAddr = objMember.mail 
 WebPage = objMember.wwwHomePage 
 Addr1 = objMember.streetAddress 
 City = objMember.l 
 State = objMember.st 
 ZipCode = objMember.postalCode 
 Title = ObjMember.Title 
 Department = objMember.Department 
 Company = objMember.Company 
 Manager = ObjMember.Manager 
 Profile = objMember.profilePath 
 LoginScript = objMember.scriptpath 
 HomeDirectory = ObjMember.HomeDirectory 
 HomeDrive = ObjMember.homeDrive 
 AdsPath = Objmember.Adspath 
 LastLogin = objMember.LastLogin 

 objmemberof=&quot;&quot;
 set objUser=getobject(Objmember.Adspath)
 objmemberOf  = objUser.GetEx(&quot;memberOf&quot;)

For Each objGroup in objmemberOf
   strList = strList &amp; objGroup &amp; vbcr
Next

MemberOf = strList
strList=&quot;&quot;
 
 
 zz = 1 &#039; Counter for array of 2ndary email addresses 
 For each email in ObjMember.proxyAddresses 
     If Left (email,5) = &quot;SMTP:&quot; Then 
 Primary = Mid (email,6) &#039; if SMTP is all caps, then it&#039;s the Primary 
     ElseIf Left (email,5) = &quot;smtp:&quot; Then 
        Secondary(zz) = Mid (email,6) &#039; load the list of 2ndary SMTP emails into Array. 
        zz = zz + 1 
     End If 
 Next 
 &#039; Write the values to Excel, using the X counter to increment the rows. 
 
 objwb.Cells(x, 2).Value = SamAccountName 
 objwb.Cells(x, 3).Value = CN 
 objwb.Cells(x, 4).Value = FirstName 
 objwb.Cells(x, 5).Value = LastName 
 objwb.Cells(x, 6).Value = Initials 
 objwb.Cells(x, 7).Value = Descrip 
 objwb.Cells(x, 8).Value = Office 
 objwb.Cells(x, 9).Value = Telephone 
 objwb.Cells(x, 10).Value = EmailAddr
 objwb.Cells(x, 11).Value = WebPage 
 objwb.Cells(x, 12).Value = Addr1 
 objwb.Cells(x, 13).Value = City 
 objwb.Cells(x, 14).Value = State 
 objwb.Cells(x, 15).Value = ZipCode 
 objwb.Cells(x, 16).Value = Title 
 objwb.Cells(x, 17).Value = Department 
 objwb.Cells(x, 18).Value = Company 
 objwb.Cells(x, 19).Value = Manager 
 objwb.Cells(x, 20).Value = Profile 
 objwb.Cells(x, 21).Value = LoginScript 
 objwb.Cells(x, 22).Value = HomeDirectory 
 objwb.Cells(x, 23).Value = HomeDrive 
 objwb.Cells(x, 24).Value = Adspath 
 objwb.Cells(x, 25).Value = LastLogin 
 objwb.Cells(x,26).Value = Primary 
 objwb.Cells(x,27).Value = MemberOf
 
 &#039; Write out the Array for the 2ndary email addresses. 
 For ll = 1 To 20 
 objwb.Cells(x,27+ll).Value = Secondary(ll) 
 Next 
 &#039; Blank out Variables in case the next object doesn&#039;t have a value for the property 
 SamAccountName = &quot;-&quot; 
 Cn = &quot;-&quot; 
 FirstName = &quot;-&quot; 
 LastName = &quot;-&quot; 
 initials = &quot;-&quot; 
 Descrip = &quot;-&quot; 
 Office = &quot;-&quot; 
 Telephone = &quot;-&quot; 
 EmailAddr = &quot;-&quot; 
 WebPage = &quot;-&quot; 
 Addr1 = &quot;-&quot; 
 City = &quot;-&quot; 
 State = &quot;-&quot; 
 ZipCode = &quot;-&quot; 
 Title = &quot;-&quot; 
 Department = &quot;-&quot; 
 Company = &quot;-&quot; 
 Manager = &quot;-&quot; 
 Profile = &quot;-&quot; 
 LoginScript = &quot;-&quot; 
 HomeDirectory = &quot;-&quot; 
 HomeDrive = &quot;-&quot; 
 Primary = &quot;-&quot; 
 For ll = 1 To 20 
 Secondary(ll) = &quot;&quot; 
 MemberOf=&quot;&quot;
Next 

    End If 


   
    &#039; If the AD enumeration runs into an OU object, call the Sub again to itinerate 
    
    If objMember.Class = &quot;organizationalUnit&quot; or OBjMember.Class = &quot;container&quot; Then 
        enumMembers (objMember) 
    End If 
 Next 
 End Sub 
 
Sub ExcelSetup(shtName) &#039; This sub creates an Excel worksheet and adds Column heads to the 1st row 
 Set objExcel = CreateObject(&quot;Excel.Application&quot;) 
 Set objwb = objExcel.Workbooks.Add 
 Set objwb = objExcel.ActiveWorkbook.Worksheets(shtName) 
 Objwb.Name = &quot;Active Directory Users&quot; &#039; name the sheet 
 objwb.Activate 
 objExcel.Visible = True 
 objwb.Cells(1, 2).Value = &quot;SamAccountName&quot; 
 objwb.Cells(1, 3).Value = &quot;CN&quot; 
 objwb.Cells(1, 4).Value = &quot;FirstName&quot; 
 objwb.Cells(1, 5).Value = &quot;LastName&quot; 
 objwb.Cells(1, 6).Value = &quot;Initials&quot; 
 objwb.Cells(1, 7).Value = &quot;Descrip&quot; 
 objwb.Cells(1, 8).Value = &quot;Office&quot; 
 objwb.Cells(1, 9).Value = &quot;Telephone&quot; 
 objwb.Cells(1, 10).Value = &quot;Email&quot; 
 objwb.Cells(1, 11).Value = &quot;WebPage&quot; 
 objwb.Cells(1, 12).Value = &quot;Addr1&quot; 
 objwb.Cells(1, 13).Value = &quot;City&quot; 
 objwb.Cells(1, 14).Value = &quot;State&quot; 
 objwb.Cells(1, 15).Value = &quot;ZipCode&quot; 
 objwb.Cells(1, 16).Value = &quot;Title&quot; 
 objwb.Cells(1, 17).Value = &quot;Department&quot; 
 objwb.Cells(1, 18).Value = &quot;Company&quot; 
 objwb.Cells(1, 19).Value = &quot;Manager&quot; 
 objwb.Cells(1, 20).Value = &quot;Profile&quot; 
 objwb.Cells(1, 21).Value = &quot;LoginScript&quot; 
 objwb.Cells(1, 22).Value = &quot;HomeDirectory&quot; 
 objwb.Cells(1, 23).Value = &quot;HomeDrive&quot; 
 objwb.Cells(1, 24).Value = &quot;Adspath&quot; 
 objwb.Cells(1, 25).Value = &quot;LastLogin&quot; 
 objwb.Cells(1, 26).Value = &quot;Primary SMTP&quot; 
 objwb.Cells(1, 27).Value = &quot;MemberOf&quot; 
 End Sub 
 MsgBox &quot;Done&quot; &#039; show that script is complete 


__________________________________________________

Try it.. I can modify it as per needs. Like I am now writting not to include disabled users in this sheet. If you have different needs.. let me also know

Manish]]></description>
		<content:encoded><![CDATA[<p>Hi All&#8230;&#8230;&#8230;&#8230;&#8230;. I have written a VB script that captures all the Tab details (even the groups user belongs to , MemberOf Tab) and export it to Excel. Then, you can import it to MS Access database&#8230;&#8230;&#8230;&#8230;.</p>
<p>Dim ObjWb<br />
 Dim ObjExcel<br />
Dim MemberOf<br />
Dim objUser, objGroup<br />
Dim strList<br />
Dim objmemberOf<br />
 Dim x, zz<br />
 Set objRoot = GetObject(&#8220;LDAP://RootDSE&#8221;)<br />
 strDNC = objRoot.Get(&#8220;DefaultNamingContext&#8221;)<br />
 Set objDomain = GetObject(&#8220;LDAP://&#8221; &amp; strDNC) &#8216; Bind to the top of the Domain using LDAP using ROotDSE </p>
<p>Call ExcelSetup(&#8220;Sheet1&#8243;) &#8216; Sub to make Excel Document<br />
 x = 1<br />
 Call enummembers(objDomain) </p>
<p> Sub enumMembers(objDomain)<br />
 On Error Resume Next<br />
 Dim Secondary(20) &#8216; Variable to store the Array of 2ndary email alias&#8217;s<br />
 For Each objMember In objDomain &#8216; go through the collection </p>
<p> If ObjMember.Class = &#8220;user&#8221; Then &#8216; if not User object, move on.<br />
 x = x +1 &#8216; counter used to increment the cells in Excel     </p>
<p>objwb.Cells(x, 1).Value = objMember.Class<br />
    &#8216; I set AD properties to variables so if needed you could do Null checks or add if/then&#8217;s to this code<br />
    &#8216; this was done so the script could be modified easier.<br />
 SamAccountName = ObjMember.samAccountName<br />
 Cn = ObjMember.CN<br />
 FirstName = objMember.GivenName<br />
 LastName = objMember.sn<br />
 initials = objMember.initials<br />
 Descrip = objMember.description<br />
 Office = objMember.physicalDeliveryOfficeName<br />
 Telephone = objMember.telephonenumber<br />
 EmailAddr = objMember.mail<br />
 WebPage = objMember.wwwHomePage<br />
 Addr1 = objMember.streetAddress<br />
 City = objMember.l<br />
 State = objMember.st<br />
 ZipCode = objMember.postalCode<br />
 Title = ObjMember.Title<br />
 Department = objMember.Department<br />
 Company = objMember.Company<br />
 Manager = ObjMember.Manager<br />
 Profile = objMember.profilePath<br />
 LoginScript = objMember.scriptpath<br />
 HomeDirectory = ObjMember.HomeDirectory<br />
 HomeDrive = ObjMember.homeDrive<br />
 AdsPath = Objmember.Adspath<br />
 LastLogin = objMember.LastLogin </p>
<p> objmemberof=&#8221;"<br />
 set objUser=getobject(Objmember.Adspath)<br />
 objmemberOf  = objUser.GetEx(&#8220;memberOf&#8221;)</p>
<p>For Each objGroup in objmemberOf<br />
   strList = strList &amp; objGroup &amp; vbcr<br />
Next</p>
<p>MemberOf = strList<br />
strList=&#8221;"</p>
<p> zz = 1 &#8216; Counter for array of 2ndary email addresses<br />
 For each email in ObjMember.proxyAddresses<br />
     If Left (email,5) = &#8220;SMTP:&#8221; Then<br />
 Primary = Mid (email,6) &#8216; if SMTP is all caps, then it&#8217;s the Primary<br />
     ElseIf Left (email,5) = &#8220;smtp:&#8221; Then<br />
        Secondary(zz) = Mid (email,6) &#8216; load the list of 2ndary SMTP emails into Array.<br />
        zz = zz + 1<br />
     End If<br />
 Next<br />
 &#8216; Write the values to Excel, using the X counter to increment the rows. </p>
<p> objwb.Cells(x, 2).Value = SamAccountName<br />
 objwb.Cells(x, 3).Value = CN<br />
 objwb.Cells(x, 4).Value = FirstName<br />
 objwb.Cells(x, 5).Value = LastName<br />
 objwb.Cells(x, 6).Value = Initials<br />
 objwb.Cells(x, 7).Value = Descrip<br />
 objwb.Cells(x, 8).Value = Office<br />
 objwb.Cells(x, 9).Value = Telephone<br />
 objwb.Cells(x, 10).Value = EmailAddr<br />
 objwb.Cells(x, 11).Value = WebPage<br />
 objwb.Cells(x, 12).Value = Addr1<br />
 objwb.Cells(x, 13).Value = City<br />
 objwb.Cells(x, 14).Value = State<br />
 objwb.Cells(x, 15).Value = ZipCode<br />
 objwb.Cells(x, 16).Value = Title<br />
 objwb.Cells(x, 17).Value = Department<br />
 objwb.Cells(x, 18).Value = Company<br />
 objwb.Cells(x, 19).Value = Manager<br />
 objwb.Cells(x, 20).Value = Profile<br />
 objwb.Cells(x, 21).Value = LoginScript<br />
 objwb.Cells(x, 22).Value = HomeDirectory<br />
 objwb.Cells(x, 23).Value = HomeDrive<br />
 objwb.Cells(x, 24).Value = Adspath<br />
 objwb.Cells(x, 25).Value = LastLogin<br />
 objwb.Cells(x,26).Value = Primary<br />
 objwb.Cells(x,27).Value = MemberOf</p>
<p> &#8216; Write out the Array for the 2ndary email addresses.<br />
 For ll = 1 To 20<br />
 objwb.Cells(x,27+ll).Value = Secondary(ll)<br />
 Next<br />
 &#8216; Blank out Variables in case the next object doesn&#8217;t have a value for the property<br />
 SamAccountName = &#8220;-&#8221;<br />
 Cn = &#8220;-&#8221;<br />
 FirstName = &#8220;-&#8221;<br />
 LastName = &#8220;-&#8221;<br />
 initials = &#8220;-&#8221;<br />
 Descrip = &#8220;-&#8221;<br />
 Office = &#8220;-&#8221;<br />
 Telephone = &#8220;-&#8221;<br />
 EmailAddr = &#8220;-&#8221;<br />
 WebPage = &#8220;-&#8221;<br />
 Addr1 = &#8220;-&#8221;<br />
 City = &#8220;-&#8221;<br />
 State = &#8220;-&#8221;<br />
 ZipCode = &#8220;-&#8221;<br />
 Title = &#8220;-&#8221;<br />
 Department = &#8220;-&#8221;<br />
 Company = &#8220;-&#8221;<br />
 Manager = &#8220;-&#8221;<br />
 Profile = &#8220;-&#8221;<br />
 LoginScript = &#8220;-&#8221;<br />
 HomeDirectory = &#8220;-&#8221;<br />
 HomeDrive = &#8220;-&#8221;<br />
 Primary = &#8220;-&#8221;<br />
 For ll = 1 To 20<br />
 Secondary(ll) = &#8220;&#8221;<br />
 MemberOf=&#8221;"<br />
Next </p>
<p>    End If </p>
<p>    &#8216; If the AD enumeration runs into an OU object, call the Sub again to itinerate </p>
<p>    If objMember.Class = &#8220;organizationalUnit&#8221; or OBjMember.Class = &#8220;container&#8221; Then<br />
        enumMembers (objMember)<br />
    End If<br />
 Next<br />
 End Sub </p>
<p>Sub ExcelSetup(shtName) &#8216; This sub creates an Excel worksheet and adds Column heads to the 1st row<br />
 Set objExcel = CreateObject(&#8220;Excel.Application&#8221;)<br />
 Set objwb = objExcel.Workbooks.Add<br />
 Set objwb = objExcel.ActiveWorkbook.Worksheets(shtName)<br />
 Objwb.Name = &#8220;Active Directory Users&#8221; &#8216; name the sheet<br />
 objwb.Activate<br />
 objExcel.Visible = True<br />
 objwb.Cells(1, 2).Value = &#8220;SamAccountName&#8221;<br />
 objwb.Cells(1, 3).Value = &#8220;CN&#8221;<br />
 objwb.Cells(1, 4).Value = &#8220;FirstName&#8221;<br />
 objwb.Cells(1, 5).Value = &#8220;LastName&#8221;<br />
 objwb.Cells(1, 6).Value = &#8220;Initials&#8221;<br />
 objwb.Cells(1, 7).Value = &#8220;Descrip&#8221;<br />
 objwb.Cells(1, 8).Value = &#8220;Office&#8221;<br />
 objwb.Cells(1, 9).Value = &#8220;Telephone&#8221;<br />
 objwb.Cells(1, 10).Value = &#8220;Email&#8221;<br />
 objwb.Cells(1, 11).Value = &#8220;WebPage&#8221;<br />
 objwb.Cells(1, 12).Value = &#8220;Addr1&#8243;<br />
 objwb.Cells(1, 13).Value = &#8220;City&#8221;<br />
 objwb.Cells(1, 14).Value = &#8220;State&#8221;<br />
 objwb.Cells(1, 15).Value = &#8220;ZipCode&#8221;<br />
 objwb.Cells(1, 16).Value = &#8220;Title&#8221;<br />
 objwb.Cells(1, 17).Value = &#8220;Department&#8221;<br />
 objwb.Cells(1, 18).Value = &#8220;Company&#8221;<br />
 objwb.Cells(1, 19).Value = &#8220;Manager&#8221;<br />
 objwb.Cells(1, 20).Value = &#8220;Profile&#8221;<br />
 objwb.Cells(1, 21).Value = &#8220;LoginScript&#8221;<br />
 objwb.Cells(1, 22).Value = &#8220;HomeDirectory&#8221;<br />
 objwb.Cells(1, 23).Value = &#8220;HomeDrive&#8221;<br />
 objwb.Cells(1, 24).Value = &#8220;Adspath&#8221;<br />
 objwb.Cells(1, 25).Value = &#8220;LastLogin&#8221;<br />
 objwb.Cells(1, 26).Value = &#8220;Primary SMTP&#8221;<br />
 objwb.Cells(1, 27).Value = &#8220;MemberOf&#8221;<br />
 End Sub<br />
 MsgBox &#8220;Done&#8221; &#8216; show that script is complete </p>
<p>__________________________________________________</p>
<p>Try it.. I can modify it as per needs. Like I am now writting not to include disabled users in this sheet. If you have different needs.. let me also know</p>
<p>Manish</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 3/10 queries in 0.043 seconds using memcached
Object Caching 265/271 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-23 05:01:10 -->